很基本,但我正在创建一款游戏,我将在游戏中拥有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数组中的值?请发布您面临的具体问题,而不是要求海报为您编写代码。 – ryadavilli