我正在创建一个二十一点程序。我需要检查if the dealer's hand is greater than the players hand
and also less then 21.
变量
dValue1 is the dealer's first card
dValue2 is the dealer's second card
pValue1 is the player's first card
pValue2 is the player's second card
我试过这样做:
if(dValue1 + dValue2 > pValue1 + pValue2 && < 21)
但我收到以下错误: 类型不匹配:无法从int转换为布尔值。 运营商&amp;&amp;未定义参数类型boolean,int。
如果有人可以提出另一种方法来做到这一点,或者我只是简单地犯了语法错误,我真的很感激。
要澄清:我想检查经销商卡的价值是否高于玩家的卡,但也低于21。
答案 0 :(得分:3)
你必须将条件分成两部分。
if ((dValue1 + dValue2) > (pValue1 + pValue2) && (dValue1 + dValue2) < 21)