public class Grid2 { public static void main(String argv[]) { // Process the command line arguments. int numCols = Integer.parseInt(argv[0]); int numRows = Integer.parseInt(argv[1]); // For the number of rows, print the "comb shape." for (int i = 1; i <= numRows; i++) { printComb(numCols); } printBottom(numCols); // Print the extra bottom row. } /* * A functional abstraction for printing a "comb shape." */ public static void printComb(int width) { for (int i = 1; i <= width; i++) { System.out.print("._"); } System.out.println("."); for (int i = 1; i <= width; i++) { System.out.print("| "); } System.out.println("|"); } /* * A functional abstraction for printing the bottom row of a grid. */ public static void printBottom(int width) { for (int i = 1; i <= width; i++) { System.out.print("._"); } System.out.println("."); } }