Hello everyone,
So i am working on a simple game to play in the java console where you can choose between three cups This is my first program ive written myself. the only problem I am having is making sure two of the cups return false while one is true. Some ideas would be greatly appreciated ballIncup() assigns a true or false variable but it keep returning true when I test it out.
import java.util.Random;
import java.util.Scanner;
public class pickAcup {
static Scanner input = new Scanner(System.in);
static Random ball = new Random();
static String name;
static int turn = 1;
static boolean cup1, cup2, cup3 = false;
static String choice;
public static void main(String[] args){
intro();
ballIncup();
playerChoice();
}
public static void intro(){
// Introduction Takes in player name and welcomes them to the game
System.out.println("Welcome to pick a cup please enter your name");
name= input.nextLine();
System.out.println("Hello " + name);
}
public static void ballIncup(){
cup1 = ball.nextBoolean();
cup2 = ball.nextBoolean();
cup3 = ball.nextBoolean();
if(cup1 == false && cup2 == false){
cup3 = true;
}else if(cup1 == false && cup3 == false){
cup2 = true;
}else if(cup2 == false && cup3 == false){
cup1 = true;
}
}
public static void playerChoice(){
System.out.println("Please pick cup 1, cup 2, or cup 3" + name);
choice = input.nextLine();
if(choice.equals("cup 1")){
if(cup1 = true){
System.out.println("You win!");
}else if(cup1 = false){
System.out.println("Please pick again");
}
}
}
}