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

Question 1) – Prepare an abstract class called Shape for representing a general

ID: 3755118 • Letter: Q

Question

Question 1) –

Prepare an abstract class called Shape for representing a general shape that can be drawn on the screen, using the following UML diagram as a guide. It should have a default constructor as well as a constructor that specifies a starting point for the shape, accessor and mutator methods for the colour of the shape, a mutator method for specifying a control point which determines the size of the shape, and an abstract draw method for drawing the shape based on the starting and control points

Explanation / Answer

Please find the Shape.java class below:-

1. Shape.java

public abstract class Shape {

// Default Constructor

public Shape(){

}

// a constructor that specifies a starting point for the shape

public Shape(int xCoord, int yCoord){

}

// colour of the shape

protected String shapeColor;

protected int controlXCoord;

protected int controlYCoord;

// an abstract draw method for drawing the shape based on the starting and control points

public abstract void draw();

public void setControlXCoord(int controlXCoord) {

this.controlXCoord = controlXCoord;

}

public void setControlYCoord(int controlYCoord) {

this.controlYCoord = controlYCoord;

}

public String getShapeColor() {

return shapeColor;

}

public void setShapeColor(String shapeColor) {

this.shapeColor = shapeColor;

}

}

Please let me know in case of any clarifications required. Thanks!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote