-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
197 lines (186 loc) · 7.74 KB
/
Program.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/*
Main class for Logic 2018 - a program for solving logical derivations
-Problem sets taken from Logic 2010 https://logiclx.humnet.ucla.edu/
Author: Peter Vlasveld
*/
using System;
using System.Collections.Generic;
using System.IO;
namespace Logic2018
{
//main class
class Program
{
static void Main(string[] args)
{
//variables
string userID = null;
var stillRunning = true;
var saveCloud = new SaveCloud();
var mainInventory = new List<Premise>();
var writer = new Reader();
Console.OutputEncoding = System.Text.Encoding.UTF8;
//Testing
/*Console.WriteLine("Premise:");
var testingCommand = Console.ReadLine();
problemConstructor = new ProblemConstructor();
var testPremise = problemConstructor.MakeCustom(testingCommand);
Console.WriteLine(testPremise.GetPremise());*/
//check connection to database
if (saveCloud.CheckConnection())
{
}
else
{
Console.WriteLine("It appears that there is a problem with the internet connection.");
Console.WriteLine("This program uses the internet to generate problem sets.");
Console.WriteLine("Please reconnect to the internet before playing.");
stillRunning = false;
goto MainMenu;
}
//user loop
InitialLoop:
var initialInt = 0;
//user menu
Console.WriteLine("Choose from the following options:");
Console.WriteLine("1. New User");
Console.WriteLine("2. Existing User");
Console.Write("Input:");
//error checking
try
{
initialInt = Convert.ToInt32(Console.ReadLine());
}
catch (Exception)
{
Console.WriteLine("That's not a number. Try again.");
goto InitialLoop;
}
//select input
switch (initialInt)
{
case 1:
saveCloud.CreateNewUser();
userID = saveCloud.GetUserID();
break;
case 2:
Console.Write("User ID:");
userID = Console.ReadLine();
System.Console.Write("password: ");
string password = null;
while (true)
{
var key = System.Console.ReadKey(true);
if (key.Key == ConsoleKey.Enter)
//Console.WriteLine(' ');
break;
password += key.KeyChar;
Console.Write('*');
}
if (saveCloud.UserAuthenticate(userID, password))
{
saveCloud.UserTableCheck(userID);
break;
}
else
{
Console.WriteLine("UserID and password did not match what is in the system. Please try again.");
goto InitialLoop;
}
default:
Console.WriteLine("Invalid response. Try again.");
goto InitialLoop;
}
writer.AddTenBlankLines();
writer.ReadWholeFile("textFiles/Intro.txt");
//main menu
MainMenu:
while (stillRunning)
{
//main menu
Console.WriteLine("Choose from the following menu options:");
Console.WriteLine("1. Tutorials");
Console.WriteLine("2. Problem set 1 (Working with Conditionals)");
Console.WriteLine("3. Problem Set 2 (Intro to Theorems)");
Console.WriteLine("4. Problem Set 3 (Final Conditional Battle)");
Console.WriteLine("5. Problem Set 4 (Welcome to the AND, OR and Biconditional)");
Console.WriteLine("6. Problem Set 5 (Practicing Makes Perfect)");
int mainChoice = 0;
var mainInput = "";
//error checking
try
{
mainInput = Console.ReadLine();
mainChoice = Convert.ToInt32(mainInput);
}
catch (Exception)
{
if (mainInput == "exit")
{
stillRunning = false;
goto MainMenu;
}
/*else if (mainInput == "fill-table") //for updating argument_display tables.
{
Console.Write("Which table?");
var tableInput = Convert.ToInt32(Console.ReadLine());
saveCloud.FillArgumentDisplayTable(tableInput);
}*/
else
{
Console.WriteLine("That is not a valid choice. Try Again");
goto MainMenu;
}
}
//select choice
switch (mainChoice)
{
case 1:
TutorialMenu:
Console.WriteLine("Choose a tutorial, or type 'exit' to return to the main menu:");
Console.WriteLine("1. The Very Basics (Direct Derivations)");
Console.WriteLine("2. Indirect Derivations");
Console.WriteLine("3. Conditional Derivations and extra Show statements");
Console.Write("Choice:");
var tutorialChoice = Console.ReadLine();
var tutorialChoiceInt = 0;
Tutorial tutorial;
try
{
tutorialChoiceInt = Convert.ToInt32(tutorialChoice);
}
catch (Exception)
{
if (tutorialChoice=="exit") goto MainMenu;
else
{
Console.WriteLine("That is not even a number. Try Again, or type 'exit' to go to main menu.");
goto TutorialMenu;
}
}
switch (tutorialChoiceInt)
{
case 1:
tutorial = new Tutorial(1,userID);
goto MainMenu;
case 2:
tutorial = new Tutorial(2,userID);
goto MainMenu;
case 3:
tutorial = new Tutorial(3,userID);
goto MainMenu;
default:
Console.WriteLine("That is not a valid choice. Try Again or type 'exit' to go to main menu.");
goto TutorialMenu;
}
case 2: case 3: case 4: case 5: case 6:
var problemSet = new ProblemSet((mainChoice-1), userID);
goto MainMenu;
default:
Console.WriteLine("Invalid choice. Try again.");
goto MainMenu;
}
}
}
}
}