You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ManualBot.java 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package Praktikum05;
  2. import java.util.Scanner;
  3. public class ManualBot extends Bot {
  4. protected ManualBot(String[] args) {
  5. super(args);
  6. }
  7. private Scanner input = new Scanner(System.in);
  8. @Override
  9. protected char nextMove(View view) throws Exception{
  10. boolean exit = false;
  11. while(!exit){
  12. System.out.println("Enter command: ");
  13. String command = input.nextLine();
  14. if(command != null){
  15. switch(command){
  16. case "w":
  17. return '^';
  18. case "a":
  19. return '<';
  20. case "s":
  21. return 'v';
  22. case "d":
  23. return '>';
  24. case "q":
  25. command = null;
  26. break;
  27. default:
  28. System.out.println("Kommando nicht verfügbar bitte einen anderes Kommando eingeben");
  29. break;
  30. }
  31. }
  32. }
  33. input.close();
  34. throw new Exception("Beendet");
  35. }
  36. public static void main(String args[]){
  37. Bot bot = new ManualBot(args);
  38. bot.run();
  39. }
  40. }