Difference between revisions of "Main Section 2018"
(Created page with "The main method initialises any default values, loads the allowed-words from a local static method (GetAllowedWords) & creates the tile directory. Then it starts a continual l...") |
|||
Line 1: | Line 1: | ||
+ | <syntaxhighlight lang=csharp> | ||
+ | static void Main(string[] args) | ||
+ | { | ||
+ | List<String> AllowedWords = new List<string>(); | ||
+ | Dictionary<Char, int> TileDictionary = new Dictionary<char, int>(); | ||
+ | int MaxHandSize = 20; | ||
+ | int MaxTilesPlayed = 50; | ||
+ | int NoOfEndOfTurnTiles = 3; | ||
+ | int StartHandSize = 15; | ||
+ | string Choice = ""; | ||
+ | Console.WriteLine("++++++++++++++++++++++++++++++++++++++"); | ||
+ | Console.WriteLine("+ Welcome to the WORDS WITH AQA game +"); | ||
+ | Console.WriteLine("++++++++++++++++++++++++++++++++++++++"); | ||
+ | Console.WriteLine(""); | ||
+ | Console.WriteLine(""); | ||
+ | LoadAllowedWords(ref AllowedWords); | ||
+ | CreateTileDictionary(ref TileDictionary); | ||
+ | while (Choice != "9") | ||
+ | { | ||
+ | DisplayMenu(); | ||
+ | Console.Write("Enter your choice: "); | ||
+ | Choice = Console.ReadLine(); | ||
+ | if (Choice == "1") | ||
+ | { | ||
+ | PlayGame(AllowedWords, TileDictionary, true, StartHandSize, MaxHandSize, MaxTilesPlayed, NoOfEndOfTurnTiles); | ||
+ | } | ||
+ | else if (Choice == "2") | ||
+ | { | ||
+ | PlayGame(AllowedWords, TileDictionary, false, 15, MaxHandSize, MaxTilesPlayed, NoOfEndOfTurnTiles); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
The main method initialises any default values, loads the allowed-words from a local static method (GetAllowedWords) & creates the tile directory. Then it starts a continual loop until the players enters the option '9' on the home-screen. Here an if/else statement seperates two function calls to the same method with the only different parameters being a boolean (randomstart) and the size of the StartHand. | The main method initialises any default values, loads the allowed-words from a local static method (GetAllowedWords) & creates the tile directory. Then it starts a continual loop until the players enters the option '9' on the home-screen. Here an if/else statement seperates two function calls to the same method with the only different parameters being a boolean (randomstart) and the size of the StartHand. |
Latest revision as of 12:59, 14 November 2017
static void Main(string[] args)
{
List<String> AllowedWords = new List<string>();
Dictionary<Char, int> TileDictionary = new Dictionary<char, int>();
int MaxHandSize = 20;
int MaxTilesPlayed = 50;
int NoOfEndOfTurnTiles = 3;
int StartHandSize = 15;
string Choice = "";
Console.WriteLine("++++++++++++++++++++++++++++++++++++++");
Console.WriteLine("+ Welcome to the WORDS WITH AQA game +");
Console.WriteLine("++++++++++++++++++++++++++++++++++++++");
Console.WriteLine("");
Console.WriteLine("");
LoadAllowedWords(ref AllowedWords);
CreateTileDictionary(ref TileDictionary);
while (Choice != "9")
{
DisplayMenu();
Console.Write("Enter your choice: ");
Choice = Console.ReadLine();
if (Choice == "1")
{
PlayGame(AllowedWords, TileDictionary, true, StartHandSize, MaxHandSize, MaxTilesPlayed, NoOfEndOfTurnTiles);
}
else if (Choice == "2")
{
PlayGame(AllowedWords, TileDictionary, false, 15, MaxHandSize, MaxTilesPlayed, NoOfEndOfTurnTiles);
}
}
}
The main method initialises any default values, loads the allowed-words from a local static method (GetAllowedWords) & creates the tile directory. Then it starts a continual loop until the players enters the option '9' on the home-screen. Here an if/else statement seperates two function calls to the same method with the only different parameters being a boolean (randomstart) and the size of the StartHand.