-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
72 lines (60 loc) · 2.32 KB
/
Program.cs
File metadata and controls
72 lines (60 loc) · 2.32 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System;
using System.Collections.Generic;
namespace KnowledgePath
{
class Program
{
static void Main()
{
Console.OutputEncoding = System.Text.Encoding.UTF8;
/* Load Tree from JSON */
string treeFileName = "Tree.json";
Tree tree = new(treeFileName);
Console.WriteLine("'To know what is possible is the most beautiful thing, for then you may dream of what may be.'");
Console.WriteLine("Welcome to the Knowledge Path, press 1-3 to begin or to select an option.");
Console.WriteLine("You can press 'q' at any time to quit.");
Console.WriteLine("");
// Initialize path tracker and input parser
int currentNode = 0;
PathTracker pathTracker = new(tree, currentNode);
InputParser input = new();
// Get starting input
input.GetUserChoice();
while (!input.quit)
{
Console.Clear();
List<int> nextSubjects = tree.GetUpTo3NextSubjects(currentNode);
if (nextSubjects.Count is 0) // Runs if selected subject has no child nodes (i.e. path is complete)
{
pathTracker.PrintPath();
input.GetUserChoice();
if (input.restart)
{
currentNode = 0;
pathTracker = new(tree, currentNode);
}
}
else // Runs if child nodes exist
{
tree.PrintBlurbs(tree.GetBlurbsForSubjects(nextSubjects));
input.GetUserChoice();
while (input.selection == InputParser.Selection.Invalid)
{
Console.WriteLine("Please enter 1-3 or press 'q' to quit.\n");
input.GetUserChoice();
}
}
if (!input.restart && !input.quit)
{
currentNode = nextSubjects[(int)input.selection - 1];
pathTracker.Add(tree, currentNode);
}
else
{
input.restart = false;
}
}
Environment.Exit(0);
}
}
}