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

Consider the Abstract SimpleMovingShape class that we developed previously. Comp

ID: 3713311 • Letter: C

Question

Consider the Abstract SimpleMovingShape class that we developed previously. Complete the SimpleMovingRectangle class. The SimpleMovingRectangle subclass contains: .two overloaded constructors . an overriding tostring) method that returns "Rectangle:" and the string retumed from the toString() in the super class . an overriding draw() method that outputs a string description of the instance in the format "rect (x-coordinate, y-coordinate) width x height" Write the simpleMovingRectangleclass in the answer box below assuming that the abstract SimpleMovingShape class has been done for you in the Code Runner System. For example Test Result SimpleMovingRectangle r1-new SimpleMovingRectangle) System.out.println(r1); Rectangle: (o, ),x SimpleMovingRectangle r1 = new simpleMovingRectangle(new Point(10, System.out.println(r1); 10), 50, 80); Rectangle: (18, 19) 50 88

Explanation / Answer

class SimpleMovingRectangle extends SimpleMovingShape . //because we need to override its methods

{

double width, height,x,y;

SimpleMovingRectangle ( )

{

public String toString() //overriding the toString()

return Rectangle;

}

SimpleMovingRectangle (double x, double y, double width, double height )

{

public void draw()

[

super.draw();

System.out.println("rec("+ x +","+y+")"+width+"x"+height);

}

}

}

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