Advertisement
michelksu

Untitled

Jun 12th, 2015
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. //Main.java
  2.  
  3. /*
  4. * To change this license header, choose License Headers in Project Properties.
  5. * To change this template file, choose Tools | Templates
  6. * and open the template in the editor.
  7. */
  8. package pkg7.pkg8d;
  9.  
  10. import java.util.Scanner;
  11.  
  12. public class Main {
  13.  
  14. private static final Scanner input = new Scanner(System.in);
  15.  
  16. public static void main(String[] args) {
  17.  
  18. Turtle turtle = new Turtle();
  19.  
  20. String userInput;
  21. int walkLength;
  22.  
  23. do {
  24. turtle.printCommands();
  25. userInput = input.nextLine().trim();
  26. switch (userInput) {
  27. case "1":
  28. turtle.setPenUp();
  29. break;
  30. case "2":
  31. turtle.setPenDown();
  32. break;
  33. case "3":
  34. turtle.turnRight();
  35. break;
  36. case "4":
  37. turtle.turnLeft();
  38. break;
  39. case "6":
  40. turtle.printFloor();
  41. break;
  42. case "9":
  43. break;
  44. default:
  45. if (userInput.startsWith("5,")) {
  46. walkLength = Integer.parseInt(userInput.substring(2));
  47. turtle.turtleWalk(walkLength);
  48. } else {
  49. System.out.println("Invalid choice.");
  50. }
  51. }
  52. } while (!"9".equals(userInput));
  53.  
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement