public class Shape { public enum Type { SQUARE, UP_TRIANGLE, DOWN_TRIANGLE, RHOMBUS; /* ***** * ***** ***** ***** ** **** ***** ***** *** *** ***** ***** **** ** ***** ***** ***** * ***** */ } //Instance Variables private Shape.Type type; private int size; private String picture; //Constructor public Shape(Shape.Type type, int size, char symbol) { if ( size < 1 ) throw new RuntimeException("Size must be positive"); this.size = size; this.type = type; this.picture = ""; switch ( this.type ) { case SQUARE : square(symbol); break; case UP_TRIANGLE : upTriangle(symbol); break; case DOWN_TRIANGLE: downTriangle(symbol); break; case RHOMBUS : rhombus(symbol); } this.picture = this.picture.trim(); } //Accessor public int getSize() { return this.size; } //Accessor public Shape.Type getType() { return this.type; } //Override public String toString() { return this.picture; } //**************** Helper Methods **************** //Exercise 1: Nested Loops //Complete the picture of this Shape as a Square private void square(char dot) { for (int row = 1; row <= this.size; row++) { } } //Complete the picture of this Shape as an Up_Triangle private void upTriangle(char dot) { for (int row = 1; row <= this.size; row++) { } } //Complete the picture of this Shape as a Down_Triangle private void downTriangle(char dot) { for (int row = 1; row <= this.size; row++) { } } //Complete the picture of this Shape as a Rhombus private void rhombus(char dot) { for (int row = 1; row <= this.size; row++) { } } /* //Exercise 2: Using a Helper //A helper to compose a line segment of given width and symbol private static String lineSegment(int width, char symbol) { String segment = ""; return segment; } //Complete the picture of this Shape as a Square private void square(char dot) { for (int row = 1; row <= this.size; row++) { } } //Complete the picture of this Shape as an Up_Triangle private void upTriangle(char dot) { for (int row = 1; row <= this.size; row++) { } } //Complete the picture of this Shape as a Down_Triangle private void downTriangle(char dot) { for (int row = 1; row <= this.size; row++) { } } //Complete the picture of this Shape as a Rhombus private void rhombus(char dot) { for (int row = 1; row <= this.size ; row++) { } } */ }