【发布时间】:2012-11-29 12:04:38
【问题描述】:
非常基本,但我正在创建一个游戏,我将在游戏中有 2 到 4 名玩家我需要知道如何询问用户会有多少玩家,然后将这个数量存储在我的数组中以供以后使用?!
这是我到目前为止写的内容
{
int NumberofPlayers;
{
do
{
Console.WriteLine("Please enter number of players (2-4): ");
String StringNumberOfPlayers = Console.ReadLine();
NumberofPlayers = int.Parse(StringNumberOfPlayers);
}
while (NumberofPlayers > 4 || NumberofPlayers < 2);
}
// need get the number of players and set the required elements in
// playerPositions to 0 on the board
}
static int [] PlayerPositions = new int [4];
static void Main()
{
ResetGame();
}
}
}
【问题讨论】:
-
我看到你得到了玩家的数量,那么是什么阻止你重置 PlayerPositions 数组中的值?请发布您面临的具体问题,而不是要求发帖者为您编写代码。