我正在为石头,纸,剪刀的游戏创建不同的方法。 我被困在如何正确创建“ displayRoundResult”和“ displayMatchResult”方法上。我不知道该朝哪个方向走。
// display round results
private void displayRoundResult(int p1Score, int p2Score)
{
int winningHand;
if (winningHand == 1)
{
p1Score++;
}
if (winningHand == 2)
{
p2Score++;
}
else if (winningHand == 0)
{
p1Score = p1Score;
p2Score = p2Score;
}
//if winning equals ... then p1score goes up by 1 or p2score does
}
private int winningHand(char player1, char player2)
{
int winningHand;
char R,P,S;
//tie
if (player1 == (player2))
{
winningHand = 0;
}
//if player 1 wins
if (player1 == R && player2 == S)
{
winningHand = 1;
}
if (player1 == S || player2 == P )
{
winningHand = 1;
}
if (player1 == P || player2 == R)
{
winningHand = 1;
}
//if player 2 wins
if (player1 == S || player2 == R)
{
winningHand = 2;
}
if (player1 == P || player2 == S)
{
winningHand = 2;
}
if (player1 == R || player2 == P)
{
winningHand = 2;
}
return winningHand;
}
// display match results
private void displayMatchResult(int round, int p1Score, int p2Score)
{
if (p1Score > p2Score)
{
}
}
displayRoundResult
我创建了winingHand方法,该方法确定哪个玩家获胜,并基于此我希望该方法根据获胜价值添加一个点(0 =平局,1 =玩家1获胜,2 =玩家2获胜)
我认为这种方法很好吗?
displayMatchResult 我想用这种方法告诉我谁赢得了整体比赛。因此,如果玩家1的得分更高,则他们赢得了本轮比赛。
**对于这个项目,我的老师给了我这些空白的方法来填写。我不确定int回合如何发挥作用?我不要求答案,请提供一些指导。