Create a child of SimpleGeometricObject called MyPentagon . MyPentagon has 1 property - side.    Add instance variable (embed Data Encapsulation)  Add constructors: no-args and the one that take all the data fields as an input (including the parent data)  create getters and setters  create getPerimeter() method   generate toString() method that will print all the information about the object including its perimeter  Add main method and create 2 MyPentagon objects with parameters of your choice using constructors you created.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Create a child of SimpleGeometricObject called MyPentagon . MyPentagon has 1 property - side.

 

 Add instance variable (embed Data Encapsulation)

 Add constructors: no-args and the one that take all the data fields as an input (including the parent data)

 create getters and setters


 create getPerimeter() method 

 generate toString() method that will print all the information about the object including its perimeter

 Add main method and create 2 MyPentagon objects with parameters of your choice using constructors you created. 

 

```java
public class SimpleGeometricObject {
    private String color = "white";
    private boolean filled;
    private java.util.Date dateCreated;
    
    /** Construct a default geometric object */
    public SimpleGeometricObject() {
        dateCreated = new java.util.Date();
    }
    
    /** Construct a geometric object with the specified color
     *  and filled value */
    public SimpleGeometricObject(String color, boolean filled) {
        dateCreated = new java.util.Date();
        this.color = color;
        this.filled = filled;
    }
    
    /** 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,
     *  its 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 java.util.Date getDateCreated() {
        return dateCreated;
    }
    
    /** Return a string representation of this object */
    public String toString() {
        return "created on " + dateCreated + "\ncolor: " + color +
        " and filled: " + filled;
    }
}
```

## Explanation:

The provided code is a Java class named `SimpleGeometricObject`. It defines geometric objects with attributes such as color, filled status, and date of creation.

### Components of the Class:

- **Private Fields:**
  - `String color`: Holds the color of the geometric object with a default value "white".
  - `boolean filled`: Indicates whether the object is filled.
  - `java.util.Date dateCreated`: Stores the date when the object is created.

- **Constructors:**
  - **Default Constructor:** Initializes an object with the default color "white" and the current date.
  - **Parameterized Constructor:** Initializes an object with a specified color and filled status along with the current date.

- **Methods:**
  - `getColor()`: Returns the color of the object.
  - `setColor(String color)`: Sets a new color for the object.
  - `isFilled()`: Returns the filled status.
  - `setFilled(boolean filled)`: Sets a
Transcribed Image Text:```java public class SimpleGeometricObject { private String color = "white"; private boolean filled; private java.util.Date dateCreated; /** Construct a default geometric object */ public SimpleGeometricObject() { dateCreated = new java.util.Date(); } /** Construct a geometric object with the specified color * and filled value */ public SimpleGeometricObject(String color, boolean filled) { dateCreated = new java.util.Date(); this.color = color; this.filled = filled; } /** 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, * its 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 java.util.Date getDateCreated() { return dateCreated; } /** Return a string representation of this object */ public String toString() { return "created on " + dateCreated + "\ncolor: " + color + " and filled: " + filled; } } ``` ## Explanation: The provided code is a Java class named `SimpleGeometricObject`. It defines geometric objects with attributes such as color, filled status, and date of creation. ### Components of the Class: - **Private Fields:** - `String color`: Holds the color of the geometric object with a default value "white". - `boolean filled`: Indicates whether the object is filled. - `java.util.Date dateCreated`: Stores the date when the object is created. - **Constructors:** - **Default Constructor:** Initializes an object with the default color "white" and the current date. - **Parameterized Constructor:** Initializes an object with a specified color and filled status along with the current date. - **Methods:** - `getColor()`: Returns the color of the object. - `setColor(String color)`: Sets a new color for the object. - `isFilled()`: Returns the filled status. - `setFilled(boolean filled)`: Sets a
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education