public static void main(String[] args) {
		Scanner scan = new Scanner(System.in); // Create a new Scanner object that takes input from the System.in input stream to get the commands

		System.out.println("Enter the number of rows in the board, or 0 for the default number (20):"); // Prompt the user to enter the width of the board
		int rows = scan.nextInt(); // Get the user's input
		System.out.println("Enter the number of columns in the board, or 0 for the default number (20):"); // Prompt the user to enter the height of the board
		int columns = scan.nextInt(); // Get the user's input

		System.out.println(); // Print an empty line for space

		rows = rows != 0 ? rows : 20; // If the user entered a width of 0, set the width to 20
		columns = columns != 0 ? columns : 20; // If the user entered a height of 0, set the height to 20

		TurtleGraphics tg = new TurtleGraphics(rows, columns); // Create a new TurtleGraphics object

		System.out.println(tg); // Print the board

		System.out.println("Enter:"); // This line and the next 6 list the option the user has
		System.out.println("\"u\" to put the pen up,");
		System.out.println("\"d\" to put the pen down,");
		System.out.println("\"l\" to turn left,");
		System.out.println("\"r\" to turn right,");
		System.out.println("\"e\" to use an eraser,");
		System.out.println("\"p\" to draw,");
		System.out.println("\"t\" to toggle the pen,");
		System.out.println("\"f x\" to move forward x spaces, where x is an integer,");
		System.out.println("or \"q\" to quit");

		String choice = scan.nextLine().toLowerCase(); // Get the user's choice and convert it to all lowercase so that the code is case insensitive


		while (!choice.equals("q")) { // Repeat until the user decides to quit the program
			switch (choice) { // Do different things, depending on the user's input
			case "u": // If the user decided to put the pen up:
				tg.setPenDown(false); // Set the state of the pen to false (up)
				break; // Leave the switch so that the other cases aren't executed

			case "d": // If the user decided to put the pen down:
				tg.setPenDown(true); // Set the state of the pen to true (down)
				break; // Leave the switch so that the other cases aren't executed

			case "l": // If the user decided to turn left:
				tg.turn(true); // Turn the turtle 90deg to the left (counterclockwise)
				break; // Leave the switch so that the other cases aren't executed

			case "r": // If the user decided to turn left:
				tg.turn(false); // Turn the turtle 90deg to the right (clockwise)
				break; // Leave the switch so that the other cases aren't executed

			case "e":
				tg.setEraser(true); // Set the eraser to true
				break; // Leave the switch so that the other cases aren't executed

			case "p":
				tg.setEraser(false); // Set the eraser to false so that the user can draw
				break; // Leave the switch so that the other cases aren't executed

			case "t":
				tg.togglePen(); // Toggle the pen
				break; // Leave the switch so that the other cases aren't executed

			case "q": // If the user decided to quit:
				break; // Do nothing because the end-of-program message and so forth is handled after the while loop

			default: // If none of the cases above are applicable:
				if (choice.length() > 2 && choice.substring(0, 2).equals("f ")) { // Check if the user decided to move forward
					int numForward = Integer.parseInt(choice.substring(2, choice.length())); // Get the number of spaces to move forward

					tg.forward(numForward); // Move forward the number of spaces indicated by the user
				}

				else {System.out.println("I don't understand \"" + choice + "\". Please check your spelling.");} // If the user entered an invalid command, let him/her know
			}

			System.out.println(); // Print an empty line for spacing
			System.out.println(tg); // Print the board

			System.out.println("Enter \"l\" to turn left, \"r\" to turn right, \"u\" to lift the pen, \"d\" to lower the pen, \"e\" to use an eraser, \"p\" to draw, \"t\" to toggle the pen, \"f x\" to move forward x spaces, or \"q\" to quit: "); // Print the one-line version of the menu

			choice = scan.nextLine().toLowerCase(); // Get the user's choice and convert it to all lowercase so that the code is case insensitive
		}

		// After the user quits:
		System.out.println("Thank you for using!"); // Print a closing message
		scan.close(); // Close the scanner object

	}