trying to do some basic java and hit a wall. Doing a random guessing game where you guess either 1 or 2 and a random answer every time to make it more spicy. When i'm writing this i can't make my if statement which in my head should work properly but obviously doesn't. Gonna post the code here and see if you guys can be of some help.
package TestPackage;
import java.util.Random;
class Chansen
{
public static void main( String args[] )
{
int c;
boolean Finished = true;
Random randomNum = new Random();
int result = randomNum.nextInt(2) +1;
System.out.println(result);
if (Finished == false);
while (true){
System.out.println("Välj alternativ (1/2): ");
c = Keyboard.readChar();
if ( result == c); {
System.out.println("Grattis! Du vann en lyxkryssning"); }
else if (result == 2); System.out.println("Nitlott!");
else { Finished = false;
System.out.println("Du skulle valt alternativ 'A' eller 'B'");
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire