S
Spellsleeper
Gast
Ich hab Probleme bei meinem Nimm-Spiel irgendwie hab ichs geschafft, dass das Spiel nie endet.
Java:
import javax.swing.*;
public class NimmSpiel {
/**
* Daniel Ritter
* Aufgabe:NimmSpiel
* 12/05/2011
*/
public static void main(String[] args) {
int objects=new java.util.Random().nextInt(100)+1;
int start=JOptionPane.showConfirmDialog(null, "Es gibt "+objects+" Stäbchen!\nWollen sie beginnen?","Wollen sie beginnen?",JOptionPane.YES_NO_OPTION);
String[] redChoice={"1","2","3"};
int tempStart=0;
while(objects>0){
//Solange noch Streichhölzer da sind
if(tempStart%2==start){
//Beginne, wenn du es so wolltest
int temp=JOptionPane.showOptionDialog(null, objects+"Stäbchen\nWieviel Stäbchen wollen sie wegnehmen?", "Reduzierung", JOptionPane.OK_OPTION, JOptionPane.PLAIN_MESSAGE, null, redChoice, redChoice[0]);
objects-=(temp+1);
tempStart++;
}else{
tempStart++;
JOptionPane.showMessageDialog(null, objects);
if(objects==1);
objects-=1;
if(objects==2);
objects-=1;
if(objects==3);
objects-=2;
if(objects==5||objects==9);
objects--;
if(objects==4);
objects-=3;
if(objects<9&&objects>5);
objects=objects-(objects-5);
if(objects<12&&objects>9);
objects=objects-(objects-9);
if(objects>12);
objects-=3;
}
}if(tempStart%2==start){
JOptionPane.showMessageDialog(null, "Die Maschienen sind mächtig , schade das du keine Maschiene bist!");
}else{JOptionPane.showMessageDialog(null, "Schaff dir bei Gelegenheit mal nen neuen Rechner an!");}
}
}