Answered step by step
Verified Expert Solution
Link Copied!

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 GeometricObject(String 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 setColor(String color)
{
this.color = color;
}
public boolean getFilled()
{
return filled;
}
public void setFilled(boolean 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 side1, side2, and side3 with default values 1.0 to
denote three sides of the triangle.
ii. A no-arg constructor that creates a default triangle.
iii. A constructor that creates a triangle with the specified side1, side2, and side3.
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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Databases Concepts And Practice

Authors: Suzanne W Dietrich

1st Edition

1119827949, 9781119827948

More Books

Students also viewed these Databases questions

Question

Am I expecting too much from other people?

Answered: 1 week ago