Aufgabe 1 Zurück
public class Blatt2_Aufgabe1 {
public static void main
(String[] args) {
int com;
int you;
int you1;
int com1;
char weiter;
int würfelseiten;
int rounds;
String name;
int round;
round = 1;
com = 0;
you = 0;
System.out.println("Ich erklär nun wie das Spiel
Funktioniert");
System.out.println("Du kannst gleich bestimmen wie viele Runden du
Spielst");
System.out.println("Der,
der am Ende am meisten Runden gewonnen hat, gewinnt das Spiel");
name =
Kon.readString("Geben sie ihren Namen ein! ") ;
System.out.print("Guten Tag " +name);
rounds =
Kon.readInt(" geben Sie die Anzahl der Runden ein die Sie spielen wollen!
");
würfelseiten =
Kon.readInt("Geben Sie die Anzahl der Würfelseiten ein die sie haben
wollen!(min4) ");
if (würfelseiten < 4)
{
System.out.println("error | Die Würfelzahl ist zu klein");
System.out.println("Der
Würfel hat nun 4 Seiten");
würfelseiten = 4;
}
for (round = 1 ;round
<= rounds ; round = round+1); {
com1 =
(int)(Math.random()*würfelseiten+1);
you1 =
(int)(Math.random()*würfelseiten+1);
System.out.println("Der Computer würfelt nun...");
System.out.println("Der Computer hat eine " +com1 +"
gewürfelt");
weiter =
Kon.readChar("Drücke 'x' und 'Enter' um zu würfeln!");
while (weiter != 'x')
{
weiter = Kon.readChar ("Drücke 'x' und
'Enter' um zu würfeln!");
}
System.out.println("Du hast eine " +you1 +"
gewürfelt");
com = com + com1;
you = you + you1;
round = round + 1;
if (com < you) {
System.out.println("Bravo,
du hast gewonnen!");
}
if (com > you) {
System.out.println("Du hast leider verloren! Vieleicht gewinnst du
beim nächsten mal.");
}
if (com == you) {
System.out.println("Ein Unentschieden");
}
}
}
}