// Marty Stepp, CSE 142, Autumn 2008 // This program draws a figure of an ASCII mirror. // This version uses a class constant to make the figure resizable. public class Mirror2 { public static final int SIZE = 4; public static void main(String[] args) { line(); topHalf(); bottomHalf(); line(); } public static void line() { System.out.print("#"); for (int equals = 1; equals <= 4 * SIZE; equals++) { System.out.print("="); } System.out.println("#"); } public static void topHalf() { for (int line = 1; line <= SIZE; line++) { // print contents of each line // | System.out.print("|"); // spaces for (int space = 1; space <= (-2 * line + (2 * SIZE)); space++) { System.out.print(" "); } // <> System.out.print("<>"); // . for (int dot = 1; dot <= 4 * line - 4; dot++) { System.out.print("."); } // <> System.out.print("<>"); // spaces for (int space = 1; space <= (-2 * line + (2*SIZE)); space++) { System.out.print(" "); } // | System.out.println("|"); } } // same as top half only in reverse order public static void bottomHalf() { for (int line = SIZE; line >= 1; line--) { // print contents of each line // | System.out.print("|"); // spaces for (int space = 1; space <= (-2 * line + (2 * SIZE)); space++) { System.out.print(" "); } // <> System.out.print("<>"); // . for (int dot = 1; dot <= 4 * line - 4; dot++) { System.out.print("."); } // <> System.out.print("<>"); // spaces for (int space = 1; space <= (-2 * line + (2*SIZE)); space++) { System.out.print(" "); } // | System.out.println("|"); } } }