Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

There are 5 parts of this program. I am posting all separate to get you the chan

ID: 3648845 • Letter: T

Question

There are 5 parts of this program. I am posting all separate to get you the chance to earn most points so please do not respond any of the post with some garbage code.
Thank you!
Part 1: Modify GeometricObject

Modify the GeometricObject class from the text so that the user can select the color of the object, and whether or not it is filled. (The Date of the object should still be set to the time of that object's creation.)


public class GeometricObject {
private String color = "white";
private boolean filled;
private java.util.Date dateCreated;

/** Construct a default geometric object */
public GeometricObject() {
dateCreated = new java.util.Date();
}

/** Construct a geometric object with the specified color
* and filled value */
public GeometricObject() (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 + " color: " + color +
" and filled: " + filled;
}

}

Explanation / Answer

If I understand correctly, and you are just creating a constructor that takes parameters of the color and whether it's filled (and not actually getting them from the user in this class, because it looks like you are required to write a driver class for that)...then what you posted is close, but won't compile. You have some extra parenthesis that aren't allowed in your second constructor. Here's the complete code with that fixed: public class GeometricObject { private String color = "white"; private boolean filled; private java.util.Date dateCreated; /** Construct a default geometric object */ public GeometricObject() { dateCreated = new java.util.Date(); } /** Construct a geometric object with the specified color * and filled value */ public GeometricObject(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 + " color: " + color + " and filled: " + filled; } }