Design aclassnamedTriangle that extends the abstractclassGeometricObject: Design a class named Rectangle that extendsthe abstractclassGeometricObject: Design a class named Hexagonthat extendsthe...

1 answer below »

Design aclassnamedTriangle that extends the abstractclassGeometricObject:
Design a class named Rectangle that extendsthe abstractclassGeometricObject:
Design a class named Hexagonthat extendsthe abstractclassGeometricObject:



** Each class file must be in its own file, separate from the main.20 Points.
**Use the Geometric Object code below as your superclass


>> Copy Below This Line


import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;


abstract class GeometricObject {
private String color = "white";
private String name = "";
private boolean filled;
private LocalDateTime dateCreated;


/** Construct a default geometric object */
protected GeometricObject() {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");

dateCreated = LocalDateTime.now();

}


/** Construct a geometric object with color and filled value */
protected GeometricObject(String name, String color, boolean filled) {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");

dateCreated = LocalDateTime.now();

this.color = color;
this.filled = filled;
this.name = name;
}


/** Return color */
public String getColor() {
return color;
}


/** Set a new color */
public void setColor(String color) {
this.color = color;
}


/** Return filled. Since filled is boolean,
* the get method is named isFilled */
public boolean isFilled() {
return filled;
}


/** Set a new filled */
public void setFilled(boolean filled) {
this.filled = filled;
}


/** Get dateCreated */
public LocalDateTime getDateCreated() {
return dateCreated;
}


@Override
public String toString() {
return name + "\n" + "created on " + dateCreated + "\ncolor: " + color +
" and filled: " + filled;
}


/** Abstract method getArea */
public abstract double getArea();


/** Abstract method getPerimeter */
public abstract double getPerimeter();


/** Abstract method getPerimeter */
public abstract void drawAscii();


}


>> Copy Above This Line



Example of drawAscii method output.


triangle.drawAscii();


The Triangleclasscontains:




    • Onedoubledata fieldsnamedside

    • Adefault constructorthat creates a triangle with sides of length 1.0





    • Aconstructorthat creates a triangle with specified values for sides, name, color, and filled.





    • Accessormethodfor sides

    • Mutatormethodfor sides





    • All functioning Abstractmethods



The Rectangleclasscontains:




    • Twodoubledata fieldsnamedwidth, height

    • Adefault constructorthat creates a Rectangle with all sides of length 1.0





    • Aconstructorthat creates a Rectangle with specified values for width, height, name,color ,and filled





    • Accessormethodsfor width and height

    • Mutatormethodsfor width and height





    • All functioning Abstractmethods



The Hexagonclasscontains:




    • doubledata fieldnamedsides for all sides

    • All sides on the Hexagon are the same size.

    • Adefault constructorthat creates a Hexagon with all sides of length 1.0





    • Aconstructorthat creates a Hexagon with specified values for sides, name, color, and filled






    • Accessormethodfor sides

    • Mutatormethodfor sides

    • All functioning Abstractmethods





Create a driver program that asks the user what geometric object type they would like to create.
Ask the user to enter the required data for the object they selected.
Print the area and perimeterof the object they created.
Print the object color.
Print the if the object is filled
Print the date created.
Print the Ascii representation of the shape.
Ask the user if they would like to create another object, if no end the program.

Answered Same DayJan 31, 2022

Answer To: Design aclassnamedTriangle that extends the abstractclassGeometricObject: Design a class named...

Aditya answered on Jan 31 2022
108 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here