Professional Documents
Culture Documents
*;
abstract interface I{
}
abstract interface N{
}
abstract interface T{
}
public class Main implements N, I, T
{
public static void main(String[] args) {
System.out.println("Let’s play a game called \"Odds or Evens\"");
boolean choiceFlag;
choiceFlag = false;
do {
if (choice.equals("O")) {
System.out.println(name + " has picked odds! The Program will be
evens.");
choiceFlag = true;
} else if (choice.equals("E")) {
System.out.println(name + " has picked evens! The Program will be
odds.");
choiceFlag = true;
} else {
do {
System.out.println(name + "! you have made wrong choice.");
System.out.print("Choose either O or E, which one do you like?
");
choice = del.next();
if(choice.equals("O") || choice.equals("E"))
break;
} while (!(choice.equals("E")));
}
} while( choiceFlag == false);
System.out.println("--------------------------------------------------");
System.out.println();
boolean flag;
flag = false;
do {
if(choice.equals("E") && userNumber % 2 == 0){
if( computerNumber % 2 != 0)
flag = true;
else if(computerNumber % 2 == 0)
{
do{
computerNumber = rand.nextInt(6);
}while( computerNumber % 2 == 0 );
}
}
else if(choice.equals("O") && userNumber % 2 != 0){
if( computerNumber % 2 == 0)
flag = true;
else if(computerNumber % 2 != 0)
{
do{
computerNumber = rand.nextInt(6);
}while( computerNumber % 2 != 0 );
}
}
else {
flag = false;
System.out.print("Choose \"fingers\" according to selected \"" +
choice + "\" choice: ");
userNumber = del.nextInt();
}
} while (flag == false);
if( userNumber % 2 == 0)
System.out.println("That means " + name + " wins!");
else
System.out.println("That means computer wins!");
}
else{
System.out.println( sum + " is ...odd!");
if( userNumber % 2 != 0)
System.out.println("That means " + name + " wins!");
else
System.out.println("That means computer wins!");
}
System.out.println("--------------------------------------------------");
System.out.println();
}
}