Aylin, Isabella, Edasu, Jasmin
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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package bot;
  2. import java.util.Scanner;
  3. public class ManualBot extends Bot {
  4. private Scanner scanner;
  5. public ManualBot(String[] args) {
  6. super(args);
  7. this.scanner = new Scanner(System.in);
  8. }
  9. public static void main(String[] args) {
  10. ManualBot manualBot = new ManualBot(args);
  11. manualBot.run();
  12. }
  13. @Override
  14. protected char nextMove(View view) throws Exception {
  15. Scanner scanner = new Scanner(System.in);
  16. char move;
  17. do {
  18. System.out.println("Bitte geben Sie einen Steuerbefehl ein (w, s, a, d, q): ");
  19. move = scanner.nextLine().toLowerCase().charAt(0);
  20. } while (!isValidMove(move));
  21. return move;
  22. }
  23. private boolean isValidMove(char move) {
  24. switch (move) {
  25. case 'w':
  26. case 's':
  27. case 'a':
  28. case 'd':
  29. case 'q':
  30. return true;
  31. default:
  32. System.out.println("Falsche Taste. Bitte geben Sie w, s, a, d oder q ein.");
  33. return false;
  34. }
  35. }
  36. public void run() {
  37. startCommunication();
  38. // hier muss die Logik für die Verbindung implementiert werden
  39. }
  40. }