Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Main.java
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package pkg7.pkg8d;
- import java.util.Scanner;
- public class Main {
- private static final Scanner input = new Scanner(System.in);
- public static void main(String[] args) {
- Turtle turtle = new Turtle();
- String userInput;
- int walkLength;
- do {
- turtle.printCommands();
- userInput = input.nextLine().trim();
- switch (userInput) {
- case "1":
- turtle.setPenUp();
- break;
- case "2":
- turtle.setPenDown();
- break;
- case "3":
- turtle.turnRight();
- break;
- case "4":
- turtle.turnLeft();
- break;
- case "6":
- turtle.printFloor();
- break;
- case "9":
- break;
- default:
- if (userInput.startsWith("5,")) {
- walkLength = Integer.parseInt(userInput.substring(2));
- turtle.turtleWalk(walkLength);
- } else {
- System.out.println("Invalid choice.");
- }
- }
- } while (!"9".equals(userInput));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement