// CSE 142, Summer 2008 (Helene Martin) // Draw a scalable ASCII mirror. // The class constant SIZE determines the height of the mirror. public class Mirror { public static final int SIZE = 4; public static void main(String[] args) { drawLine(); drawTopHalf(); drawBottomHalf(); drawLine(); } // We didn't get to this in class, but although we don't need a loop // in the version that doesn't scale, we need one here to scale right. public static void drawLine() { System.out.print("#"); for(int equals = 1; equals <= 4 * SIZE; equals++) { System.out.print("="); } System.out.println("#"); } public static void drawTopHalf() { for(int line = 1; line <= SIZE; line++) { System.out.print("|"); for(int spaces = 1; spaces <= -2 * line + 2 * SIZE; spaces++) { System.out.print(" "); } System.out.print("<>"); for(int dots = 1; dots <= 4 * line - 4; dots++) { System.out.print("."); } System.out.print("<>"); for(int spaces = 1; spaces <= -2 * line + 2 * SIZE; spaces++) { System.out.print(" "); } System.out.println("|"); } } public static void drawBottomHalf() { for(int line =SIZE; line >= 1; line--) { System.out.print("|"); for(int spaces = 1; spaces <= -2 * line + 2 * SIZE; spaces++) { System.out.print(" "); } System.out.print("<>"); for(int dots = 1; dots <= 4 * line - 4; dots++) { System.out.print("."); } System.out.print("<>"); for(int spaces = 1; spaces <= -2 * line + 2 * SIZE; spaces++) { System.out.print(" "); } System.out.println("|"); } } }