-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSchoolTracker.cs
141 lines (120 loc) · 4.12 KB
/
SchoolTracker.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
using System;
using System.Collections.Generic;
using System.Data;
using System.Threading;
namespace LinkedIn_Learning_C_Sharp
{
enum School
{
Hogwarts,
Harvard,
MIT
}
public class SchoolTracker
{
static List<Student> students = new List<Student>();
static void Main(string[] args)
{
Logger.Log("Tracker Started", priority: 0);
Payroll payroll = new Payroll();
payroll.PayAll();
var adding = true;
while (adding)
{
try
{
Logger.Log("Adding new student...");
var newStudent = new Student();
newStudent.Name = Util.Console.Ask("Enter student's name:");
newStudent.Grade = Util.Console.AskInt("Enter student's grade:");
newStudent.School = (School) Util.Console.AskInt("Enter student's school (corresponding number): \n " +
"0: Hogwarts High \n 1: Harvard \n 2: MIT \n");
newStudent.Birthday = Util.Console.Ask("Enter student's birthday:");
newStudent.Address = Util.Console.Ask("Enter student's address:");
newStudent.Phone = Util.Console.AskInt("Enter student's phone number:");
students.Add(newStudent);
Student.Count++;
Console.WriteLine("Student Count: " + Student.Count);
Console.WriteLine("Add another? y/n");
if (Console.ReadLine() != "y")
{
adding = false;
}
}
catch (FormatException message)
{
Console.WriteLine(message.Message);
}
catch (Exception e)
{
Console.WriteLine("Error adding student, please try again.");
throw;
}
}
ShowGrade("Julian");
foreach (var student in students)
{
Console.WriteLine("Student:" + student.Name + " Grade:" + student.Grade);
}
Export();
}
static void Import()
{
var importedStudent = new Student("Alison", 98, "November", "Ravencrest", 719);
Console.WriteLine(importedStudent.Name);
}
static void Export()
{
foreach (var student in students)
{
switch (student.School)
{
case School.Hogwarts:
{
Console.WriteLine("Exporting to Hogwarts");
break;
}
case School.Harvard:
{
Console.WriteLine("Exporting to Harvard");
break;
}
case School.MIT:
{
Console.WriteLine("Exporting to MIT");
break;
}
}
}
}
static void ShowGrade(string name)
{
var found = students.Find(student => student.Name == name);
Console.WriteLine(found.Name + "'s Grade: " + found.Grade);
}
}
public class Member
{
public string Name { get; set; }
public string Address { get; set; }
public int Phone { get; set; }
}
class Student : Member
{
static public int Count { get; set; } = 0;
public int Grade;
public string Birthday;
public School School;
public Student()
{
}
public Student(string name, int grade, string birthday, string address, int phone)
{
Name = name;
Grade = grade;
Birthday = birthday;
Address = address;
Phone = phone;
}
}
}