package guesscolorblocks;
import javax.swing.JOptionPane;
import java.lang.String;
public class GuessColorBlocks {
private static int colours = 0, positions = 0;
/**
*
*/
public static void main(String[] args) {
// Declare variables
int userSelection;
//Set a button text in the array
Object[] options = new String[] {"Yes", "No"};
//Display the menu to allow the user to click an option
int menu = JOptionPane.showOptionDialog(null, "Welcome to the Guess the Blocks Game!"
+ "\nReady to start?:", "Red, Green, Blue, or Yellow",
JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
if (menu == JOptionPane.YES_OPTION) {
playGame();
} else if (menu == JOptionPane.NO_OPTION) {
System.exit(0);
}
}
public static void playGame () {
String firstGuess = "", secondGuess = "", thirdGuess = "";
int red, blue, green, yellow;
String inputfirstGuess = JOptionPane.showInputDialog("Enter your first guess: (Red, Green, Blue, Yellow):");
String inputsecondGuess = JOptionPane.showInputDialog("Enter your second guess: (Red, Green, Blue, Yellow):");
String inputthirdGuess = JOptionPane.showInputDialog("Enter your third guess: (Red, Green, Blue, Yellow):");
int computerSelection = (int) ((Math.random() * 4) + 1);
if (firstGuess.equalsIgnoreCase("red")) {
firstGuess = "red";
}
else if (firstGuess.equalsIgnoreCase("green")){
firstGuess = "green";
}
else if (firstGuess.equalsIgnoreCase("blue")){
firstGuess = "blue";
}
else if (firstGuess.equalsIgnoreCase("yellow")){
firstGuess = "yellow";
}
if (secondGuess.equalsIgnoreCase("red")) {
secondGuess = "red";
}
else if (secondGuess.equalsIgnoreCase("green")){
secondGuess = "green";
}
else if (secondGuess.equalsIgnoreCase("blue")){
secondGuess = "blue";
}
else if (secondGuess.equalsIgnoreCase("yellow")){
secondGuess = "yellow";
}
if (thirdGuess.equalsIgnoreCase("red")) {
thirdGuess = "red";
}
else if (thirdGuess.equalsIgnoreCase("green")){
thirdGuess = "green";
}
else if (thirdGuess.equalsIgnoreCase("blue")){
thirdGuess = "blue";
}
else if (thirdGuess.equalsIgnoreCase("yellow")){
thirdGuess = "yellow";
}
}
}