Advertisement
Guest User

Untitled

a guest
Jan 25th, 2015
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.81 KB | None | 0 0
  1. import javax.swing.*;
  2.  
  3. class würfelnutte {
  4.     public static void main(){
  5.         Object[] multipleOptions = {"Weiter würfeln", "Übergeben"};
  6.        
  7.         int wuerfel = 5;
  8.         int punkte = 0;
  9.        
  10.         int weg = 0;
  11.        
  12.         int x = 1;
  13.        
  14.         System.out.print("Deine gewürfelten Zahlen: ");
  15.        
  16.         while(wuerfel > x){
  17.             int zahl = (int)(Math.random()*5)+1;
  18.             System.out.print(zahl + ", ");
  19.             x++;
  20.            
  21.             if(zahl == 1){
  22.                 punkte = punkte + 100;
  23.                 weg++;
  24.             }
  25.             if(zahl == 5){
  26.                 punkte = punkte + 50;
  27.                 weg++;
  28.             }
  29.         }
  30.        
  31.         while(wuerfel == x) {
  32.             int zahl = (int)(Math.random()*5)+1;
  33.             System.out.println(zahl);
  34.             x++;
  35.            
  36.             if(zahl == 1){
  37.                 punkte = punkte + 100;
  38.                 weg++;
  39.             }
  40.             if(zahl == 5){
  41.                 punkte = punkte + 50;
  42.                 weg++;
  43.             }
  44.            
  45.             if(punkte == 0){
  46.                 JOptionPane.showMessageDialog(null, "Du hast keine 1 und keine 5 gewürfelt.\nDein Punktestand beträgt 0.\n\nDer andere Spieler ist dran.");
  47.             }
  48.             else {
  49.                 JOptionPane.showOptionDialog(null,
  50.                                             "Dein Punktestand beträgt: "+punkte+"\n\nWollen Sie weiter würfeln?",
  51.                                             "Weitermachen?",
  52.                                             JOptionPane.DEFAULT_OPTION,
  53.                                             JOptionPane.INFORMATION_MESSAGE,
  54.                                             null, multipleOptions, multipleOptions[0]);
  55.             }
  56.         }
  57.        
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement