Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scanner scanner = new Scanner(System.in);
- Deck ventti = new Deck();
- int player = 0;
- int playerTotal = 0;
- int computer = 0;
- int computerTotal = 0;
- while(true) {
- System.out.println("Haluatko pelata");
- String uInput = scanner.nextLine();
- // Close While loop
- if(uInput.equalsIgnoreCase("ei")) {
- break;
- }
- // Players Game
- if(uInput.equalsIgnoreCase("hit")) {
- System.out.println(player = ventti.getCard());
- playerTotal += player;
- }else if(uInput.equalsIgnoreCase("stay")) {
- System.out.println(playerTotal);
- if(playerTotal > 21) {
- System.out.println("Hävisit pelin");
- break;
- }
- }
- }
- while(computerTotal < playerTotal) {
- // Computers game
- System.out.println(computer = ventti.getCard());
- computerTotal += computer;
- }
- //logic
- System.out.println(computerTotal);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement