Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Random;
- public class awesome
- { public static Scanner input;
- public static Random r;
- public static void main ( String[] args )
- {
- input = new Scanner(System.in);
- String name1;
- String name2;
- int pileRemove1;
- int pileRemove2;
- String pilechoose;
- String pilechoose2;
- int pile1 = 3;
- int pile2 = 4;
- int pile3 = 5;
- int counter = 0;
- System.out.println("Player 1, enter your name: ");
- name1 = input.nextLine();
- System.out.println("Player 2, enter your name: ");
- name2 = input.nextLine();
- do{
- int countercheck = counter%2;
- System.out.println("A: " + pile1 + "\tB: " + pile2 + "\tC: " + pile3);
- if(countercheck == 0){
- System.out.println(name1 + " , choose a pile: ");
- pilechoose = input.nextLine();
- System.out.println("How many to remove from the pile " + pilechoose + ": ");
- pileRemove1 = input.nextInt();
- if(pilechoose.equals("A")){
- pile1 = pile1 - pileRemove1;
- }
- else if(pilechoose.equals("B")){
- pile2 = pile2 - pileRemove1;
- }
- else if(pilechoose.equals("C")){
- pile3 = pile3 - pileRemove1;
- }
- }else{
- System.out.println(name2 + " , choose a pile: ");
- pilechoose2 = input.nextLine();
- System.out.println("How many to remove from the pile " + pilechoose2 + ": ");
- pileRemove2 = input.nextInt();
- if(pilechoose2.equals("A")){
- pile1 = pile1 - pileRemove2;
- }
- else if(pilechoose2.equals("B")){
- pile2 = pile2 - pileRemove2;
- }
- else if(pilechoose2.equals("C")){
- pile3 = pile3 - pileRemove2;
- }
- }
- counter++;
- }while(pile1 !=0 || pile2 !=0 || pile3 != 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement