Difference between revisions of "Add the ability to set the player names"
Line 8: | Line 8: | ||
string PlayerTwoName = Convert.ToString(Console.ReadLine()); | string PlayerTwoName = Convert.ToString(Console.ReadLine()); | ||
// something here... | // something here... | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | Lower down, there's a while loop that looks like this: | ||
+ | |||
+ | <syntaxhighlight lang=Csharp> | ||
+ | while (PlayerOneTilesPlayed <= MaxTilesPlayed && PlayerTwoTilesPlayed <= MaxTilesPlayed && PlayerOneTiles.Length < MaxHandSize && PlayerTwoTiles.Length < MaxHandSize) | ||
+ | { | ||
+ | HaveTurn("Player One", ref PlayerOneTiles, ref PlayerOneTilesPlayed, ref PlayerOneScore, TileDictionary, ref TileQueue, AllowedWords, MaxHandSize, NoOfEndOfTurnTiles); | ||
+ | Console.WriteLine(); | ||
+ | Console.WriteLine("Press Enter to continue"); | ||
+ | Console.ReadLine(); | ||
+ | Console.WriteLine(); | ||
+ | HaveTurn("Player Two", ref PlayerTwoTiles, ref PlayerTwoTilesPlayed, ref PlayerTwoScore, TileDictionary, ref TileQueue, AllowedWords, MaxHandSize, NoOfEndOfTurnTiles); | ||
+ | } | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 11:22, 20 November 2017
Somewhere near the top of HaveTurn, while you're declaring variables, you'll want to add the following code:
// something here...
Console.WriteLine("Player One, input your name:");
string PlayerOneName = Convert.ToString(Console.ReadLine());
Console.WriteLine("Player Two, input you name:");
string PlayerTwoName = Convert.ToString(Console.ReadLine());
// something here...
Lower down, there's a while loop that looks like this:
while (PlayerOneTilesPlayed <= MaxTilesPlayed && PlayerTwoTilesPlayed <= MaxTilesPlayed && PlayerOneTiles.Length < MaxHandSize && PlayerTwoTiles.Length < MaxHandSize)
{
HaveTurn("Player One", ref PlayerOneTiles, ref PlayerOneTilesPlayed, ref PlayerOneScore, TileDictionary, ref TileQueue, AllowedWords, MaxHandSize, NoOfEndOfTurnTiles);
Console.WriteLine();
Console.WriteLine("Press Enter to continue");
Console.ReadLine();
Console.WriteLine();
HaveTurn("Player Two", ref PlayerTwoTiles, ref PlayerTwoTilesPlayed, ref PlayerTwoScore, TileDictionary, ref TileQueue, AllowedWords, MaxHandSize, NoOfEndOfTurnTiles);
}