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 88Explanation / 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);
}
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.