// Zorah Fung // June 25, 2014 // This program prints out a hexagon, boat, stop sign and hat // using ASCII characters // // Note: This is the completed version in which we both capture // structure and eliminate internal redundancy public class FiguresFinalVersion { public static void main(String[] args) { drawHexagon(); drawBoat(); drawStopSign(); drawHat(); } // Prints out a hexagon public static void drawHexagon() { drawTop(); drawBottom(); System.out.println(); } // Prints a boat public static void drawBoat() { drawBottom(); drawLine(); System.out.println(); } // Prints a stop sign public static void drawStopSign() { drawTop(); System.out.println("| STOP |"); drawBottom(); System.out.println(); } // Prints a fez hat public static void drawHat() { drawTop(); drawLine(); } // Prints out the top half of a hexagon public static void drawTop() { System.out.println(" ______"); System.out.println(" / \\"); System.out.println("/ \\"); } // Prints out the bottom half of a hexagon public static void drawBottom() { System.out.println("\\ /"); System.out.println(" \\______/"); } // Prints a line of dashes // Note: This method is only one line of code, but it // appears in multiple places, which allows us to easily // modify this part of the picture easily in one place. public static void drawLine() { System.out.println("+--------+"); } }