// This program produces an ASCII art drawing of a tapestry. // // DEVELOPMENT NOTES: // (These notes would not be in your program's comments. They are here // to help you understand important topics or elements of this code.) // // Final version of the program. // // This version adds a constant to allow the figure to be resized by // changing a single value. Notice how the constant is declared, and // that is named in all caps. Notice also that not all expressions are // affected by the size. For example, the number of dots depends only // on the current line, not on the overall size of the tapestry. public class Tapestry3 { public static final int SIZE = 6; public static void main(String[] args) { fringe(); topHalf(); bottomHalf(); fringe(); } // Prints the fringe that appears at the top and bottom of the tapestry. public static void fringe() { // # sign System.out.print("#"); // = signs for (int i = 1; i <= 4 * SIZE; i++) { System.out.print("="); } // # sign System.out.println("#"); } // Prints the top half of the tapestry. public static void topHalf() { for (int line = 1; line <= SIZE; line++) { System.out.print("|"); // spaces for (int i = 1; i <= -2 * line + 2 * SIZE; i++) { System.out.print(" "); } System.out.print("<>"); // dots for (int i = 1; i <= 4 * line - 4; i++) { System.out.print("."); } System.out.print("<>"); // spaces for (int i = 1; i <= -2 * line + 2 * SIZE; i++) { System.out.print(" "); } System.out.println("|"); } } // Prints the bottom half of the tapestry. public static void bottomHalf() { for (int line = SIZE; line >= 1; line--) { System.out.print("|"); // spaces for (int i = 1; i <= -2 * line + 2 * SIZE; i++) { System.out.print(" "); } System.out.print("<>"); // dots for (int i = 1; i <= 4 * line - 4; i++) { System.out.print("."); } System.out.print("<>"); // spaces for (int i = 1; i <= -2 * line + 2 * SIZE; i++) { System.out.print(" "); } System.out.println("|"); } } }