Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.72 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.Random;
  3.  
  4. public class awesome
  5. {   public static Scanner input;
  6.     public static Random r;
  7.     public static void main ( String[] args )
  8.     {
  9.         input = new Scanner(System.in);
  10.         String name1;
  11.         String name2;
  12.        
  13.         int pileRemove1;
  14.         int pileRemove2;
  15.        
  16.         String pilechoose;
  17.         String pilechoose2;
  18.         int pile1 = 3;
  19.         int pile2 = 4;
  20.         int pile3 = 5;
  21.        
  22.         int counter = 0;
  23.        
  24.         System.out.println("Player 1, enter your name: ");
  25.         name1 = input.nextLine();
  26.         System.out.println("Player 2, enter your name: ");
  27.         name2 = input.nextLine();
  28.         do{
  29.         int countercheck = counter%2;
  30.         System.out.println("A: " + pile1 + "\tB: " + pile2 + "\tC: " + pile3);
  31.             if(countercheck == 0){
  32.                 System.out.println(name1 + " , choose a pile: ");
  33.                 pilechoose = input.nextLine();
  34.                 System.out.println("How many to remove from the pile " + pilechoose + ": ");
  35.                 pileRemove1 = input.nextInt();
  36.        
  37.                 if(pilechoose.equals("A")){
  38.                     pile1 = pile1 - pileRemove1;
  39.                     }
  40.                 else if(pilechoose.equals("B")){
  41.                     pile2 = pile2 - pileRemove1;
  42.                     }
  43.                 else if(pilechoose.equals("C")){
  44.                     pile3 = pile3 - pileRemove1;
  45.                     }
  46.                 }else{
  47.                     System.out.println(name2 + " , choose a pile: ");
  48.                     pilechoose2 = input.nextLine();
  49.                     System.out.println("How many to remove from the pile " + pilechoose2 + ": ");
  50.                     pileRemove2 = input.nextInt();
  51.            
  52.                     if(pilechoose2.equals("A")){
  53.                         pile1 = pile1 - pileRemove2;
  54.                         }
  55.                     else if(pilechoose2.equals("B")){
  56.                         pile2 = pile2 - pileRemove2;
  57.                     }
  58.                     else if(pilechoose2.equals("C")){
  59.                         pile3 = pile3 - pileRemove2;
  60.                         }
  61.                 }
  62.            
  63.         counter++;
  64.        
  65.         }while(pile1 !=0 || pile2 !=0 || pile3 != 0);
  66.        
  67.        
  68.  
  69.         }
  70.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement