Question: Design a new Triangle class that extends the abstract GeometricObject class. (The source code for this abstract class can be found in chapters 9, 11,
Design a new Triangle class that extends the abstract GeometricObject class. (The source code for this abstract class can be found in chapters 9, 11, & 13 in Files). Write a test program that prompts the user to enter three sides of the triangle (make sure they define an actual triangle), a color, and a Boolean value to indicate whether the triangle is filled. The program should then create a Triangle object with these sides and set the color and filled properties using the input, in addition to circle and rectangle objects. The program should display, for each of these geometric objects, the area, perimeter, color, and true or false to indicate whether it is filled or not.
GeometricObject:
abstract class GeometricObject {
private String color; private boolean filled; private Date dateCreated;
protected GeometricObject(String color, boolean filled) { this.color = color; this.filled = filled; this.dateCreated = new Date(); }
public String getColor() { return color; }
public void setColor(String color) { this.color = color; }
public boolean isFilled() { return filled; }
public void setFilled(boolean filled) { this.filled = filled; }
public Date getDateCreated() { return dateCreated; }
public void setDateCreated(Date dateCreated) { this.dateCreated = dateCreated; }
@Override public String toString() { return "created on " + dateCreated + " color: " + color + " and filled: " + filled; }
public abstract double getArea();
public abstract double getPerimeter(); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
