// Helene Martin, CSE 142 // Draws a scalable ASCII mirror. /* Note: long comments are to help you remember the process I followed in class. The comments in the code you turn in should not include pseudo-code or loop tables! #================# | <><> | 1 | <>....<> | 2 | <>........<> | 3 |<>............<>| 4 |<>............<>| 4 | <>........<> | 3 | <>....<> | 2 | <><> | 1 #================# line: #, 16 =, # */ public class Mirror { public static final int SIZE = 30; public static void main(String[] args) { printLine(); printTop(); printBottom(); printLine(); } // displays a line public static void printLine() { System.out.print("#"); for (int i = 1; i <= SIZE * 4; i++) { System.out.print("="); } System.out.println("#"); } /* | <><> | | <>....<> | | <>........<> | |<>............<>| for each of 4 lines: |, line * - 2 + 8 spaces, <>, some dots, <>, line * - 2 + 8 spaces, | line dots spaces line * - 2 line * -2 + 8 1 0 6 -2 6 2 4 4 -4 4 3 8 2 -6 2 4 12 0 -8 0 dots: line * 4 - 4 Scalling the figure: SIZE spaces 3 line * -2 + 6 4 line * -2 + 8 SIZE line * -2 + SIZE * 2 */ public static void printTop() { for (int line = 1; line <= SIZE; line++) { System.out.print("|"); for (int space = 1; space <= line * - 2 + SIZE * 2; space++) { System.out.print(" "); } System.out.print("<>"); for (int dot = 1; dot <= line * 4 - 4; dot++) { System.out.print("."); } System.out.print("<>"); for (int space = 1; space <= line * - 2 + SIZE * 2; space++) { System.out.print(" "); } System.out.println("|"); } } // prints the bottom of the diamond public static void printBottom() { for (int line = SIZE; line >= 1; line--) { System.out.print("|"); for (int space = 1; space <= line * - 2 + SIZE * 2; space++) { System.out.print(" "); } System.out.print("<>"); for (int dot = 1; dot <= line * 4 - 4; dot++) { System.out.print("."); } System.out.print("<>"); for (int space = 1; space <= line * - 2 + SIZE * 2; space++) { System.out.print(" "); } System.out.println("|"); } } }