1. Engineering
  2. Computer Science
  3. etric can be used to nm geometric objects this sign...

Question: etric can be used to nm geometric objects this sign...

Question details

etric can be used to nm geometric objects. This sign a general class class contains the properties color and filled and their appropriate get and set methods. Assume that this class also contains toString) methods. The toStringl) 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 hields named side1, side 2, and side3 with default values 2.0 to denote three sides of the triangle. Also contains Ano-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. Please take care at the input data. The input data have to be eligible (numeric values) and you have to verify the existence of objects (for example: the width and height of rectangle have to be positive numbers). If the input data is not correct, you have to ask the user to enter again the data. Note In Java terminology, a class C1 extended from another class C2 is called a subclass and C2 is called a superclass. A superclass is also referred to as a parent class or a base class, and a subclass as a child class, an extended class, or a derived class. A subclass inherits accessible data fields and methods from its superclass and may also add new data fields and methods. The formula to compute the area of a triangle is: s (side1 + side2 +side3)/2 area SQRT (s(s -side1)s - side 2)s -side3)

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution