Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- else if (a == 6){
- boolean InGame = true;
- while (InGame == true);
- System.out.println("Glückspiel: Wer näher an der zufälligen Zahl ist gewinnt! 1-100");
- System.out.println("Spieler Eins");
- double playerOne = scan.nextDouble();
- System.out.println("Spieler Zwei");
- double playerTwo = scan.nextDouble();
- double randomValue = Math.random() * 100.0;
- // Math.abs() ist eine Methode die den Betrag einer Zahl zurueck gibt.
- double spacingOne = Math.abs(playerOne - randomValue);
- double spacingTwo = Math.abs(playerTwo - randomValue);
- System.out.println("Die Random Zahl war " + randomValue);
- if (spacingOne < spacingTwo) {
- System.out.println("Spieler Eins hat gewonnen!");
- }
- if (spacingOne > spacingTwo) {
- System.out.println("Spieler Zwei hat gewonnen!");
- }
- if (spacingOne == spacingTwo) {
- System.out.println("Unentschieden!");
- }
- System.out.println("Wenn du nochmal spielen willst schreibe 'ja' wenn nicht 'nein'");
- String PlayAgain = scan.nextLine();
- if (PlayAgain == "Ja");
- }//SpielSpiel Ende
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement