diff --git a/MastermindController.cs b/MastermindController.cs index dd6630a10ea66357519e5640d31983e02a687c93..4b5ef9ade92b4ff3cdcbd1e6f4461d542f4cf259 100644 --- a/MastermindController.cs +++ b/MastermindController.cs @@ -63,9 +63,9 @@ namespace Controller } while (!checkMenu); // User selects a difficulty - Console.WriteLine(new string('=', 30)); + Console.WriteLine(new string('=', 71)); Console.WriteLine("Please select the difficulty you would like to play on:\n"); - Console.WriteLine(new string('-', 30)); + Console.WriteLine(new string('-', 71)); // Initializing temporary object to soft code MastermindGame tmpObject = new MastermindGame("easy"); @@ -73,21 +73,21 @@ namespace Controller Console.WriteLine($"\t\tThe code is {tmpObject.GetCodeLength()} digits long."); Console.WriteLine($"\t\tYou have {tmpObject.GetMaxAttempts()} attempts."); Console.WriteLine($"\t\tDuplicates: {tmpObject.GetDuplicates()}"); - Console.WriteLine(new string('-', 30)); + Console.WriteLine(new string('-', 71)); tmpObject = new MastermindGame("medium"); Console.WriteLine("Difficulty: \t[M]edium \nDescription: \tRecommended for advanced users.\n"); Console.WriteLine($"\t\tThe code is {tmpObject.GetCodeLength()} digits long."); Console.WriteLine($"\t\tYou have {tmpObject.GetMaxAttempts()} attempts."); Console.WriteLine($"\t\tDuplicates: {tmpObject.GetDuplicates()}"); - Console.WriteLine(new string('-', 30)); + Console.WriteLine(new string('-', 71)); tmpObject = new MastermindGame("hard"); Console.WriteLine("Difficulty: \t[H]ard \nDescription: \tRecommended for those who are looking for a challenge.\n"); Console.WriteLine($"\t\tThe code is {tmpObject.GetCodeLength()} digits long."); Console.WriteLine($"\t\tYou have {tmpObject.GetMaxAttempts()} attempts."); Console.WriteLine($"\t\tDuplicates: {tmpObject.GetDuplicates()}"); - Console.WriteLine(new string('=', 30)); + Console.WriteLine(new string('=', 71)); Console.WriteLine($"Press \"R\" to return to the main menu. \n"); checkMenu = false; diff --git a/MastermindGame.cs b/MastermindGame.cs index ac5a16113ebe50d559455ec0ba74efc89fe7c2ca..c2e9a6afb84527d2158aacdb5b31c9cca372d0a0 100644 --- a/MastermindGame.cs +++ b/MastermindGame.cs @@ -341,7 +341,7 @@ namespace Game /// </summary> public void DisplayBoard() { - Console.WriteLine($"\n{new string('=', 30)}"); + DisplayDecoration('=', true); Console.WriteLine($"Attempt number {currentAttempt}: "); int counter = 0; @@ -354,20 +354,7 @@ namespace Game counter++; } - switch (code_length) - { - case 4: - default: - Console.WriteLine($"\n {new string('-', 30)}"); - break; - case 6: - Console.WriteLine($"\n {new string('-', 34)}"); - break; - case 8: - Console.WriteLine($"\n {new string('-', 38)}"); - break; - - } + DisplayDecoration('-', true); // Shows hints Console.Write($"{"Recieved Hints:",-24}"); @@ -409,7 +396,24 @@ namespace Game // Shows how many attempts are left Console.WriteLine($"\nYou have {maxAttempt - currentAttempt} attempts left"); - Console.WriteLine($"{new string('=', 30)} \n"); + DisplayDecoration('=', false); + } + + private void DisplayDecoration(char letter, bool newLine) + { + switch (code_length) + { + case 4: + default: + Console.WriteLine((newLine == true) ? $"\n{new string(letter, 31)}" : $"{new string(letter, 31)}"); + break; + case 6: + Console.WriteLine((newLine == true) ? $"\n{new string(letter, 35)}" : $"{new string(letter, 35)}"); + break; + case 8: + Console.WriteLine((newLine == true) ? $"\n{new string(letter, 39)}" : $"{new string(letter, 39)}"); + break; + } } /// <summary> @@ -505,17 +509,20 @@ namespace Game // Reads and converts all the last attempts string line; + int[] input = new int[code_length]; while ((line = sr.ReadLine()) != null) { - int[] input = new int[code_length]; string[] parts = line.Split("-"); for (int i = 0; i < code_length; i++) { input[i] = Convert.ToInt32(parts[i]); } attempts[currentAttempt] = input; + GetHint(input); + currentAttempt++; } } + DisplayBoard(); } /// <summary>