Machine Problem 5, due November 14

Part of the homework for 22C:60, Fall 2005
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Assignment:

The code from machine problems 1 to 4 was designed in terms of a programming model that did not acknowledge the essential object oriented structure of the problem. What we really want is something like the following:

Lists of objects, so that the screen full of objects may be described as a list of objects.

Each object has a RENDER method. Calling object.render(c) causes that object to render itself on the screen. The parameter c is a pointer to an pair to be added to the coordinates in the object. For objects rendered directly on the screen, this parameter will be a pointer to <0,0>.

There are two classes of objects, text objects and box objects. As such, these objects are members of a polymorphic class. Text objects have starting coordinates and a text string. Box objects have starting coordinates, a height and a width. Each box object also carries a list of subsidiary objects that are to be plotted relative to that box.

We will use the convention that each object of a polymorphic class begins with a pointer to its RENDER method. The actual code for each method should be prefixed with the class name, so this machine problem requires that you write code for BOX_RENDER and TEXT_RENDER

Basic Requirements:

The file boxortext.h should contain all definitions common to the polymorphic class, while the 4 files, box.a, box.h, text.a, and text.h implement the two subclasses. The file test.a is provided, but you must provide main.a that tests the entire thing by rendering all the top-level objects in the data structure created by test.a. See http://homepage.cs.uiowa.edu/~dwjones/wwwdir/assem/hw/mp5test.txt for source code for the test program. This illustrates the use of the macros and other material you must define in your header files! This test file produces the same output as was produced by the original material in machine problem 1.

You are encouraged to use any routines from machine problems 1 to 4 that are of use in solving machine problem 5. You may use old source code from your own solutions, from solutions distributed to the class, or object files distributed to the class with these problems.

Additional Requirements:

In addition to code that runs as assigned, you are responsible for producing readable code! Clean use of indenting, and appropriate comments that explain anything slightly subtle are required! Your solution must also conform to the following specific details:

  1. Your solution must be contained in a directory named mp5.
  2. The directory should not contain any files that are not relevant to machine problem 5! Relics of machine problems 1 to 4 should not be present, unless they have been incorporated into machine problem 5.
  3. Each file must begin with an appropriate TITLE directive identifying the file and giving your name as it appears on your ID card.

Use the submit command on the departmental linux cluster to submit the directory containing your solution. Submission should be done in exactly the way it was requested for machine problem 4, except that your your choice and your directory will be mp5.

All source files in your directory will be assembled by us. We will link all object files (except link.o) to make a new link.o, and we will run this. If the output is right when we run it with our test data, you will get half credit. The other half of the credit will be assigned based on the quality of your source file and your test data. The listing file will be printed by the TA and marked up to provide feedback on the quality of your work.