// Stuart Reges // 1/14/09 // // This program produces as output an ASCII art representation of a mirror. // This version includes a class constant for drawing mirrors of different // sizes. public class Mirror2 { public static final int SIZE = 7; // change this to scale the mirror public static void main(String[] args) { line(); topHalf(); bottomHalf(); line(); } // outputs a solid line public static void line() { System.out.print("#"); for (int i = 1; i <= 4 * SIZE; i++) { System.out.print("="); } System.out.println("#"); } // outputs the top half of the mirror public static void topHalf() { for (int line = 1; line <= SIZE; line++) { System.out.print("|"); 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("<>"); 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--) { System.out.print("|"); 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("<>"); for (int space = 1; space <= (-2 * line + 2 * SIZE); space++) { System.out.print(" "); } System.out.println("|"); } } }