Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- class würfelnutte {
- public static void main(){
- Object[] multipleOptions = {"Weiter würfeln", "Übergeben"};
- int wuerfel = 5;
- int punkte = 0;
- int weg = 0;
- int x = 1;
- System.out.print("Deine gewürfelten Zahlen: ");
- while(wuerfel > x){
- int zahl = (int)(Math.random()*5)+1;
- System.out.print(zahl + ", ");
- x++;
- if(zahl == 1){
- punkte = punkte + 100;
- weg++;
- }
- if(zahl == 5){
- punkte = punkte + 50;
- weg++;
- }
- }
- while(wuerfel == x) {
- int zahl = (int)(Math.random()*5)+1;
- System.out.println(zahl);
- x++;
- if(zahl == 1){
- punkte = punkte + 100;
- weg++;
- }
- if(zahl == 5){
- punkte = punkte + 50;
- weg++;
- }
- if(punkte == 0){
- JOptionPane.showMessageDialog(null, "Du hast keine 1 und keine 5 gewürfelt.\nDein Punktestand beträgt 0.\n\nDer andere Spieler ist dran.");
- }
- else {
- JOptionPane.showOptionDialog(null,
- "Dein Punktestand beträgt: "+punkte+"\n\nWollen Sie weiter würfeln?",
- "Weitermachen?",
- JOptionPane.DEFAULT_OPTION,
- JOptionPane.INFORMATION_MESSAGE,
- null, multipleOptions, multipleOptions[0]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement