Question: Hide Assignment Information Instructions A square shaped can be considered to be a specific type of a rectangle. This is a relationship we can

Hide Assignment Information
Instructions
A square shaped can be considered to be a specific type of a rectangle. This is a relationship we can "is-a", where a square "is-a" specific type of rectangle, particularly when all 4 sides are equal. In OOP this relationship is called Inheritance.
The same idea we can follow for a circle, which "is-a" specific type of an oval.
We can also generalize where we can say all circles, ovals, squares and rectangles are different types of shapes.
Hence, shape is a general class. But can you draw a shape without knowing what specific shape you want to draw? thus a shape is what we call in OOP an abstract class - that is a class that cannot be instantiated.
However, in the spirit of programming in general, we want to create a shape factory where we can generate random shapes (with valid dimensions, i.e. no negative or zero sides or radius, and keep max dimension to 100, all integers).
Furthermore, adding one twist, if we have a canvas object, one can say that the canvas contains shapes or "has-a" list of shapes associated with it. This is a composition association in OOP, where a canvas contains, or "has-a" shape(s).
Shape is abstract class, and every shape has a unique id (an incrementing positive integer- Hint: use a static counter variable for this).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!