Using the Shape.java file available on moodle, extend the Shape class into the f
ID: 3753615 • Letter: U
Question
Using the Shape.java file available on moodle, extend the Shape class into the following classes: Rectangle: Define the draw() method to print a rectangle of height by width of the char stored in pattern Square: Override both setWidth and setHeight so that both values are always the same. Write the appropriate draw) method Triangle: Add a variable angle which will be set to 90 (for simplicity's sake). Override toString() to print the angle as well as the rest of the information Implement the draw() method.Explanation / Answer
RECTANGLE CLASS:
public class Rectangle extends Shape {
public void draw() {
System.out.print("Height of rectangle: " + height);
}
}
SQUARE CLASS:
public class Square extends Shape {
@Override
@Override
}
TRIANGLE CLASS:
public class Triangle extends Shape {
private int angle = 90;
public String toString() {
}
}
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.