Question: I need this answer in java. Consider a graphics system with 3 classes-Shape,Circle and Rectangle-that you are to design and write. Have both Cicle and
I need this answer in java.
Consider a graphics system with 3 classes-Shape,Circle and Rectangle-that you are to design and write. Have both Cicle and Rectangle inherit from Shape. In Shape, you should include the description, the x and y coordinates of the center point, a toString method, a move method, and an abstract area method. The constructor should only take the description in, then generate the x and y values randomly in the range 0 and 255. The move method takes in delta-x and a delta-y value and adds these to the x and y respectively. Since move works the same way in both child classes, make sure they cannot override it. The toString should display the description, and the x and y coordinate values.
In the Circle class add a radius value and implement the area method. The constructor should only recieve the radius and not permit a negative value(use the absolute value). Override the toString method to display everything the Shape toString displays plus the radius and area. Use the parent class toString to do most of the work.
In the Rectangle class add the length and width values and implement the area method. The constructor should only recieve the length and width and not permit negative values(use the absolute value). Override the toString method to display everything the shape toString displays plus the length, width, and area. Like the Circle toString, you should use the parent class to do most of the work.
a)Show the design of these classes using a UML diagram.
b)Implement your design in Java. Note that a test driver program is not required.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
