【发布时间】:2018-04-23 04:13:33
【问题描述】:
在下面的代码中,我尝试增加或减少用户投注(例如 10 美元)并更新余额金额。最初,余额将从 100 美元开始,随着用户继续下注,余额将更新,直到余额达到 0 美元或用户决定退出。
下面的代码在第一次下注时可以正常工作,但在第二次下注时余额不会更新。任何帮助将不胜感激!
int balance = 100;
protected int PlayerBalance()
{
int totalBalance = 0;
if (CalculateWinAmount() > 0) //CalculateWinAmount() method returns the win amount. If no wins, the method return 0
{
totalBalance += CalculateWinAmount();
}
else
{
totalBalance -= BetAmount(); //BetAmount() method returns the amount the user has bet (e.g. $5, $10..)
}
return totalBalance += balance;
}
protected void DisplayPlayerBalance()
{
playerTotalAmountLabel.Text = PlayerBalance().ToString();
}
【问题讨论】:
标签: c# asp.net .net oop methods