Question: Design a class named Triangle that extends the abstract class GeometricObject: Design a class named Rectangle that extends the abstract class GeometricObject: Design a class

Design a class named Triangle that extends the abstract class GeometricObject: Design a class named Rectangle that extends the abstract class GeometricObject: Design a class named Hexagon that extends the abstract class GeometricObject:

Each class file must be in its own file, separate from the main. 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 + " " + "created on " + dateCreated + " color: " + 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

The Triangle class contains:

  • One double data fields named side
  • A default constructor that creates a triangle with sides of length 1.0
    • A constructor that creates a triangle with specified values for sides, name, color, and filled.
    • Accessor method for sides
    • Mutator method for sides
    • All functioning Abstract methods

The Rectangle class contains:

    • Two double data fields named width, height
    • A default constructor that creates a Rectangle with all sides of length 1.0
    • A constructor that creates a Rectangle with specified values for width, height, name, color ,and filled
    • Accessor methods for width and height
    • Mutator methods for width and height
    • All functioning Abstract methods

The Hexagon class contains:

    • double data field named sides for all sides
    • All sides on the Hexagon are the same size.
    • A default constructor that creates a Hexagon with all sides of length 1.0
    • A constructor that creates a Hexagon with specified values for sides, name, color, and filled
    • Accessor method for sides
    • Mutator method for sides
    • All functioning Abstract methods

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 perimeter of 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.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!