Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. Scanner scanner = new Scanner(System.in);
  2. Deck ventti = new Deck();
  3.  
  4. int player = 0;
  5. int playerTotal = 0;
  6. int computer = 0;
  7. int computerTotal = 0;
  8.  
  9. while(true) {
  10. System.out.println("Haluatko pelata");
  11. String uInput = scanner.nextLine();
  12.  
  13. // Close While loop
  14. if(uInput.equalsIgnoreCase("ei")) {
  15. break;
  16. }
  17.  
  18. // Players Game
  19. if(uInput.equalsIgnoreCase("hit")) {
  20. System.out.println(player = ventti.getCard());
  21. playerTotal += player;
  22. }else if(uInput.equalsIgnoreCase("stay")) {
  23. System.out.println(playerTotal);
  24. if(playerTotal > 21) {
  25. System.out.println("Hävisit pelin");
  26. break;
  27. }
  28. }
  29. }
  30.  
  31. while(computerTotal < playerTotal) {
  32. // Computers game
  33. System.out.println(computer = ventti.getCard());
  34. computerTotal += computer;
  35. }
  36.  
  37. //logic
  38.  
  39. System.out.println(computerTotal);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement