Question: package shapes; public class Shape { private int height = 0; private int width = 0; private char pattern = '*'; /** * Default constructor

 package shapes; public class Shape { private int height = 0; package shapes; public class Shape { private int height = 0; private int width = 0; private char pattern = '*'; /** * Default constructor **/ public Shape() { this.height = 0; this.width = 0; } /** * Constructor * @param h height of a Shape * @param w width of a Shape **/ public Shape(int h, int w) { this.height = h; this.width = w; } /** * Setter for the height * @param h the height **/ public void setHeight(int h) { this.height = h; } /** * Setter for the width * @param w the width **/ public void setWidth(int w) { this.width = w; } /** * Setter for the pattern * @param c the char to use **/ public void setPattern(char c) { this.pattern = c; } /** * Getter for height * @return int: the height **/ public int getHeight() { return this.height; } /** * Getter for the width * @return int: the width **/ public int getWidth() { return this.width; } /** * Getter for the pattern * @return the char to use when drawing the Shape **/ public char getPattern() { return this.pattern; } /** * Overloading the default toString method * @return String: the class name, the Shape's height and width **/ public String toString() { return getClass() + " => Height: " + getHeight() + " Width: " + getWidth(); } }

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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!