很基本,但我正在創建一款遊戲,我將在遊戲中擁有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