-
Notifications
You must be signed in to change notification settings - Fork 0
/
TeamFlowchart.cs
54 lines (46 loc) · 1.54 KB
/
TeamFlowchart.cs
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
[Serializable]
public class TeamFlowchart
{
public List<string> Team { get; set; } = new List<string>();
public List<Question> Questions { get; set; } = new List<Question>();
public void Execute()
{
//Generate scoreboard obj
var scoreboard = new Dictionary<string, int>();
foreach (var member in Team)
{
scoreboard[member] = 0;
}
//Iterate through and ask each question
int q = 1;
foreach (var question in Questions)
{
Console.WriteLine(q + ") " + question.Query);
string answer;
do
{
Console.Write("[Y/N]: ");
answer = Console.ReadLine().ToUpper();
} while (answer != "Y" && answer != "N");
//If yes, apply the scores to the scoreboard
if (answer == "Y")
{
foreach (var score in question.Scoreboard)
{
if (scoreboard.ContainsKey(score.Key))
scoreboard[score.Key] += score.Value;
}
}
q++;
}
//Output results in order by score
Console.WriteLine("Results:");
var result = scoreboard.OrderByDescending(s => s.Value).ToDictionary(s => s.Key, s => s.Value);
int i = 1;
foreach (var pokemon in result)
{
Console.WriteLine(i + ") " + pokemon.Key + " - " + pokemon.Value);
i++;
}
}
}