Question: Design a general class GeometricObject can be used to model all geometric objects. This class contains the properties color and plied and their appropriate get

 Design a general class GeometricObject can be used to model all

Design a general class GeometricObject can be used to model all geometric objects. This class contains the properties color and plied and their appropriate get and set methods. Assume that this class also contains toString() methods. The toString() method returns a string representation of the object. Define the Triangle, Circle, and Rectangle classes that extend the GeometricObject class. The Triangle class inherits all accessible data fields and methods from the GeometricObject class. In addition, it has three double data fields named side1, side2, and side3 with default values 2.0 to denote three sides of the triangle. Also contains: A no-arg constructor that creates a default triangle. A constructor that creates a triangle with the specified side1, side2, and side3. The accessor methods for all three data fields. A method named getArea() that returns the area of this triangle. A method named getPerimeter() that returns the perimeter of this triangle. A method named toString() that returns a string description for the triangle implemented as follows: return 'Triangle: side1 =" + side1 + 'side2 ="side2 + "side3 = " + side3: The Circle class inherits all accessible data fields and methods from the GeometricObject class. In addition, it has a new data field, radius, and its associated get and set methods. The Circle class also contains the getArea(), getPerimeter(), and getDiameter() methods for returning the area, perimeter, and diameter of the circle. The Rectangle class inherits all accessible data fields and methods from the GeometricObject class. In addition, it has the data fields width and height and their associated get and set methods. It also contains the getArea() and getPerimeter() methods for returning the area and perimeter of the rectangle. Design a Test class which creates objects of Triangle, Circle and Rectangle and invokes the methods on these objects. The toString() method is inherited from the GeometricObject class and is invoked from a Triangle object, Circle object and a Rectangle object

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!