// Brett Wortzman // CSE142 // Section: ZZ // TA: Grace Hopper // // Prints out two diamonds and one X -- // note the \ to create escape sequences. // // This version of the program has been further // improved by recognizing the redundancy within // figures and factoring the subfigures into // their own methods as well. public class Figure3 { public static void main(String[] args) { drawDiamond(); System.out.println(); drawDiamond(); System.out.println(); drawX(); } // Draws a diamond shape. public static void drawDiamond() { drawMountain(); drawValley(); } // Draws an X shape. public static void drawX() { drawValley(); drawMountain(); } // Draws a valley (or V) shape. public static void drawValley() { System.out.println("\\ /"); System.out.println(" \\ /"); System.out.println(" \\/"); } // Draws a mountain (or ^) shape. public static void drawMountain() { System.out.println(" /\\"); System.out.println(" / \\"); System.out.println("/ \\"); } }