// Allison Obourn
// CS 141, Winter 2021
// Lecture 4

// Prints out a diamond shaped mirror in ASCII art
// The mirror is drawn with a rectangluar frame surrounding it
// The SIZE constant can be changed to alter the mirror's SIZE


public class Mirror {
   // represents the scale of the mirror
   public static final int SIZE = 20;

   public static void main(String[] args) {
      line();
      topHalf();
      bottomHalf();
      line();
   }   
   
   // prints out the top and bottom edges of the mirror
   // these are made up of = characters and beginning and ending with #
   public static void line() {
      System.out.print("#");
      for(int i = 1; i <= 4 * SIZE; i++) {
         System.out.print("=");
      }
      System.out.println("#");
   }
   
   // prints out the top half of the mirror
   // The mirror goes from a point at the top to as wide as the frame
   public static void topHalf() {
      for(int line = 1; line <= SIZE; line++) {
         printEntireLine(line);
      }
   }
   
   // prints out the bottom half of the mirror
   // The mirror goes from wide to forming a point at the bottom
   public static void bottomHalf() {
      for(int line = SIZE; line >= 1; line--) {
         printEntireLine(line);
      }
   }
   
   // prints a full line of output starting with a vertical bar, some spaces, a
   // diamond, some dots, a diamond, some spaces and a vertical bar. The amount
   // of spaces and dots is dependant on the passed in number
   public static void printEntireLine(int line) {
      System.out.print("|");
      printSpaces(line);
      System.out.print("<>");
      printDots(line);
      System.out.print("<>");
      printSpaces(line);
      System.out.println("|");
   }
   
   // takes a number of dots to print as a parameter and prints that
   // many dots staying on the same line
   public static void printDots(int line) {
      for(int i = 1; i <= 4 * line - 4; i++) {
         System.out.print(".");
      }
   }
   
   // takes a number of spaces to print as a parameter and prints that
   // many spaces staying on the same line
   public static void printSpaces(int line) {
      for(int i = 1; i <= -2 * line + 2 * SIZE; i++) {
         System.out.print(" ");
      }
   }
}