java - Make an enhanced for loop wait until something is done -
i creating black jack game. i'm @ point if ace shows up, it'll ask user if ace should low or high.
for(card card : hand){ ui.choseace = false; if(card.getpointvalue() == 1){//if ace. ui.loworhigh();//preps ui ask if ace low or high } else{ if(hand.equals(playershand)){ playerpointtotal += card.getpointvalue(); } else{ dealerpointtotal += card.getpointvalue(); } } }
in separate class...
public void loworhigh(){ hitbutton.setvisible(false); standbutton.setvisible(false); lowbutton.setvisible(true); highbutton.setvisible(true); updateui(buttonpanel); inputjtflabel.settext("is ace low or high?"); }
and buttons...
if(obj.equals(lowbutton)){ choseace = true; game.playerpointtotal += 1; } if(obj.equals(highbutton)){ choseace = true; game.playerpointtotal += 11; }
i tried adding while loop loworhigh() method...
while(!choseace){}
but when ace appears freezes. tried putting similar while loop enhanced loop. freezes.
i'd have enhanced loop wait until either highbutton or lowbutton pressed , continue left off without having save loop positions, etc.
edit: if prompted joptionpane question pause loop until joptionpane has been answered?
Comments
Post a Comment