Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Imagine the design of a graphics system that has classes for various figures (rectangles, triangles, circles, etc.) drawn on a canvas or grid. When

Java

Imagine the design of a graphics system that has classes for various figures (rectangles, triangles, circles, etc.) drawn on a canvas or grid. When designing the properties of a rectangle, for example, you might include data members for height, width, and either a center point or upper-left corner point. A circle might have only a center point (or upper-right corner point) and an edge length or radius. In this homework assignment, you will create a strawman for such a system.

"Strawman" systems don't do any real processing. Rather they are used simply to track how programs navigate through various methods. They are very useful when designing systems with hundreds or thousands of methods calls.

For this assignment, create two classes named Rectangle and Triangle. Each class should have "stubs" for constructors and methods erase, draw, center, and toString. In these stubs, each method simply prints a message telling the name of the class and which method has been called, nothing more. (For a working system, you would have to replace the definition of each of these methods with code to actually draw or erase figures on some sort of canvas, which is not part of this homework assignment.)

All methods will have a single parameter which is the name of the object being drawn. For example, when passed an object called "Rectangle 1", the draw method might print "Entering draw() for Rectangle 1".

Here is a description of the methods in Rectangle and Triangle.