import javax.swing.*;
class IndependentProject{
public static void main(String str[]){
int score=0;
int chance1=0;
int rymeagain1=0;
int guess2=0;
int a=(int)(1+Math.random()*3);
do{
JOptionPane.showMessageDialog(null,"Welcome to ANIMALS AT THE BARN!");
System.out.println("Welcome to ANIMALS AT THE BARN!");
String input1 =JOptionPane.showInputDialog(null,"How many animals are in the barn? Guess a number between 1-3");
int guess = Integer.parseInt(input1);
if(guess==a){
System.out.println(" ");
System.out.println("Good job, you got that correct there are " +a+ " animals in the barn, you gain +1 score");
JOptionPane.showMessageDialog(null,"Good job, you got that correct there are " +a+ " animals in the barn, you gain +1 score");
score=score+1;
}
else{
JOptionPane.showMessageDialog(null, "Incorrect, You get to pick another number");
String input2=JOptionPane.showInputDialog("Do you want to pick another number??\nYes \nNo");
String chance=input2;
if(chance.equalsIgnoreCase("yes")){
chance1=1;
}
//if(guessagain==b){
//System.out.println(" ");
//System.out.println("Good job, you got that correct there are " +b+ " animals in the barn, you gain +1 score");
//JOptionPane.showMessageDialog(null,"Good job, you got that correct there are " +b+ " animals in the barn, you gain +1 score");
//score=score+1;
}
//else{
//JOptionPane.showMessageDialog(null, "Incorrect, GAME OVER!");
//guessagain1=0;
//break;
//}
//if(guessagain1==0) {
//JOptionPane.showMessageDialog(null,"Thanks for playing Animals at the barn!! You left the game with "+score+" points!!");
//System.out.println("Thanks for playing Animals at the barn!! You left the game with "+score+" points!!");
// break;
//}
do{
JOptionPane.showMessageDialog(null,"There are " +a+ " animals, find the two names that rhyme together from the list of "+a+" animals in the barn");
if(a==1){
JOptionPane.showMessageDialog(null,"There is only 1 animal in this barn, you don't have to find two names that rhyme! You gain +1 score automatically!");
score=score+1;
}
else if(a==2){
String input3=JOptionPane.showInputDialog("The names of the animals are \nBetty, \nJohn, \nTeddy \nWhich of these two names rhyme? Enter the first letter of the two names, example ET(MUST BE IN ORDER FROM TOP TO BOTTOM!!)");
String two=input3;
if(two.equalsIgnoreCase("BT"))
JOptionPane.showMessageDialog(null,"CORRECT, Betty & Teddy Rhyme! You gain +1 score!!");
score=score+1;
}
else if(a==3){
String input4=JOptionPane.showInputDialog("The names of the animals are \nJohn, \nSean, \nRon, \nBOB \nWhich of these three names rhyme? Enter the first letter of the three names, example ETY(MUST BE IN ORDER FROM TOP TO BOTTOM!!)");
String three=input4;
if(three.equalsIgnoreCase("JSR"))
JOptionPane.showMessageDialog(null,"CORRECT, John & Sean & Ron Rhyme! You gain +1 score!!");
score=score+1;
}
else{
JOptionPane.showMessageDialog(null, "You did not input the names correct, you get to try again Hint: Make sure you entered the input in the correct format & order, and make sure the the names rhyme");
String input5=JOptionPane.showInputDialog("Do you want to try rhyming the numbers again??");
String rymeagain=input5;
rymeagain1=1;
}
}while(rymeagain1==1); // Lets you rhyme the numbers again
} while(chance1==1);// plays again if the number from 1-3 is incorrect
} //(String str[]){
}// class IndependentProject{