Answered step by step
Verified Expert Solution
Question
1 Approved Answer
private boolean filled; private Date dateCreated; public Geometricobject ( ) { dateCreated = new Date ( ) ; } public GeometricObject ( String color, boolean
private boolean filled;
private Date dateCreated;
public Geometricobject
dateCreated new Date;
public GeometricObjectString color, boolean filled
this.color color; "this" refers to the current object
this.filled filled;
dateCreated new Date;
public String getColor
return color;
public void setColorString color
this.color color;
public boolean getFilled
return filled;
public void setFilledboolean filled
this.filled filled;
public Date getDateCreated
return dateCreated;
public String toString
return "Created on: dateCreated Color: color Filled: filled;
Design a class named Triangle that extends Geometricobject.
The class contains:
i Three double data fields named side side and side with default values to
denote three sides of the triangle.
ii A noarg constructor that creates a default triangle.
iii. A constructor that creates a triangle with the specified side side and side
iv The accessor methods for all three data fields.
v A method named getArea that returns the area of this triangle.
vi A method named getPerimeter that returns the perimeter of this triangle.
vii. A method named toString that returns a string description with values of
three sides of the triangle.
Write a test program that prompts the user to enter three sides of the triangle, a color, and a boolean
value to indicate whether the triangle is filled. Create a Triangle object with these inputs. Display its
area, perimeter, color, and true or false to indicate whether it is filled or not
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started