Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using Mastermind;
using System;
namespace Controller
{
/// <summary>
/// Mangages the game flow, handling user interactions and processing inputs
/// </summary>
class MastermindController
{
private MastermindGame spiel;
private string difficulty;
/// <summary>
/// Starts the game and controls the sequence
/// </summary>
public void Play()
{
Console.WriteLine("Welcome to Mastermind!");
Console.WriteLine("======================");
// User selects a difficulty
Console.WriteLine("Please select the difficulty you would like to play on:\n");
Console.WriteLine("Difficulty: \t[E]asy \nDescription: \tRecommended for beginners.\n");
Console.WriteLine("Difficulty: \t[M]edium \nDescription: \tRecommended for advanced users.\n");
Console.WriteLine("Difficulty: \t[H]ard \nDescription: \tRecommended for those who are looking for a challenge.\n");
bool checkMenu = false;
do
{
switch (Console.ReadLine().ToLower())
{
case "e":
difficulty = "easy";
checkMenu = true;
break;
case "m":
difficulty = "medium";
checkMenu = true;
break;
case "h":
difficulty = "hard";
checkMenu = true;
break;
default:
Console.WriteLine("Something went wrong! Try again. Only the letters \"E\", \"M\", \"H\" are allowed. ");
break;
}
} while (!checkMenu);
// Starts Game
Console.WriteLine($"Game starts with the difficulty: {difficulty}");
spiel = new MastermindGame(difficulty);
}
}
}