-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
97 lines (84 loc) · 3.6 KB
/
Program.cs
File metadata and controls
97 lines (84 loc) · 3.6 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
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
using System;
using System.Collections.Generic;
using System.IO;
namespace ITPAssignment1
{
public class Program
{
private Dictionary<string, StudentRecordData> studentRecords = new Dictionary<string, StudentRecordData>();
private string dataDirectory = "UserData";
public static void Main()
{
Program program = new Program();
program.Initiate();
}
public void Initiate()
{
Directory.CreateDirectory(dataDirectory);
// Create JSON Class
JSON json = new JSON(studentRecords);
// Load Student Data From JSON
json.LoadPermaStudentData();
CreateNewStudentRecord studentRecordCreator = new CreateNewStudentRecord(studentRecords); // CreateStudentRecord.cs
EnterStudentMarks studentMarks = new EnterStudentMarks(studentRecords); // EnterStudentMarks.cs
UpdateStudentMarks updateStudentMarks = new UpdateStudentMarks(studentRecords); // UpdateStudentMarks.cs
ViewStudentDataRecord viewStudentDataRecord = new ViewStudentDataRecord(studentRecords); // ViewStudentRecord.cs
// Menu Options
string[] menuOptions = {
"Create A New Student Data Record",
"Input Marks For A Student",
"Update A Student's Existing Marks",
"Display An Existing Student Record",
"Exit The Program"
};
while (true)
{
DisplayMenu(menuOptions);
Console.Write("Make Your Selection From the Menu (1-5) ");
string choice = Console.ReadLine();
if (int.TryParse(choice, out int selectedOption) && selectedOption >= 1 && selectedOption <= menuOptions.Length)
{
switch (selectedOption)
{
case 1:
studentRecordCreator.CreateStudentRecord();
break;
case 2:
studentMarks.EnterStudentMarksData();
break;
case 3:
updateStudentMarks.UpdateStudentMarksData();
break;
case 4:
viewStudentDataRecord.ViewStudentData();
break;
case 5:
json.SaveStudentDataPerma();
json.LoadPermaStudentData();
Console.WriteLine("");
Console.WriteLine("Please Press Any Key To Confirm Exiting The Program");
Console.ReadKey();
Environment.Exit(0);
break;
default:
Console.WriteLine("Invalid Selection, Please Choose An Option 1 - 5");
break;
}
}
else
{
Console.WriteLine("Invalid Selection, Please Choose An Option 1 - 5");
}
}
}
private void DisplayMenu(string[] menuOptions)
{
Console.WriteLine("Menu Choices:");
for (int i = 0; i < menuOptions.Length; i++)
{
Console.WriteLine($"{i + 1}. {menuOptions[i]}");
}
Console.WriteLine("");
}
}
}