我正在为一个大学项目编写二十一点(单线程),而庄家是计算机(例如,没有玩家动作)......
有人知道我如何用 Java 编写这样的程序:
while (dealerpoints < 17)
open card and repaint frame
wait 1 sec (to run again the condition test for while)
问题是,我不希望一次绘制所有的庄家牌...
提前致谢, 加布里埃尔·索特罗
更新:这是我的代码(不起作用)
while (Dealer.getInstance().dealerPoints < 17){
Dealer.getInstance().openCard();
try {
Thread.sleep(100);
}
catch (InterruptedException e){ }
}
开卡声明:
private void openCard(){
Card temp;
temp = Deck.getInstance().myPop();
Dealer.getInstance().cards.add(temp);
Dealer.getInstance().dealerPoints += temp.getValue();
MainPanel.getInstance().updateDealerLabel(Dealer.getInstance().dealerPoints);
MainPanel.getInstance().repaint();
}