-
Notifications
You must be signed in to change notification settings - Fork 3
/
SystemTest.java
164 lines (154 loc) · 4.33 KB
/
SystemTest.java
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
import javax.swing.*;
import java.util.*;
public class SystemTest{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int identity = 0;
Student stu;
Lecture lec;
String name;
String id;
String classes;
String class_reg;
String courses_name;
TopManage administrator;
administrator = new TopManage();
List<String> Chooseclassid = new LinkedList<String> ();
int admin_choose;
int stu_choose;
int i;
while(identity != -1)
{
System.out.println("Class System\n");
System.out.println("Your identity(1-administrator,2-student,-1-exit)\n");
identity = sc.nextInt();
admin_choose = 0;
stu_choose = 0;
while(identity == 1 && admin_choose != 6)
{
System.out.println("Choices of administrator:(1-Add Students 2-Delete Students 3-Find Students 4-See class Choices 5-Register Grades 6-Exit)\n");
admin_choose = sc.nextInt();
switch(admin_choose)
{
case 1:
System.out.println("Student Name:");
sc.nextLine();
name = sc.nextLine();
System.out.println(name);
System.out.println("Student id:");
id = sc.nextLine();
System.out.println("Student class:");
classes = sc.nextLine();
stu = new Student(name, id, classes);
administrator.StudentAdd(stu);
break;
case 2:
System.out.println("Student name:");
sc.nextLine();
name = sc.nextLine();
System.out.println("Student id:");
id = sc.nextLine();
System.out.println("Student class:");
classes = sc.nextLine();
stu = new Student(name, id, classes);
administrator.DeleteStudents(stu);
break;
case 3:
System.out.println("Student id:");
sc.nextLine();
id = sc.nextLine();
stu = administrator.searchStudent(id);
if(stu == null)
System.out.println("Not found\n");
else
{
System.out.println("Student Name:");
System.out.println(stu.getName());
System.out.println("Student Class:");
System.out.println(stu.getclass());
System.out.println("Student Lectures and Grades:");
stu.printgrades();
}
break;
case 4:
System.out.println("Class Name:");
sc.nextLine();
class_reg = sc.nextLine();
Chooseclassid = administrator.searchClassChoose(class_reg);
break;
case 5:
System.out.println("Class Name:");
sc.nextLine();
class_reg = sc.nextLine();
Chooseclassid = administrator.searchClassChoose(class_reg);
administrator.LogGrades(Chooseclassid, class_reg);
break;
default:
break;
}
}
i = 1;
while(identity==2)
{
System.out.println("Please enter your id:(5 to exit)\n");
if(i==1)
{
sc.nextLine();
i = 2;
}
id = sc.nextLine();
stu = administrator.searchStudent(id);
if(id.equals(Integer.toString(5)))
break;
else
{
if(stu == null)
System.out.println("Not found!\n");
else
{
stu_choose = 0;
while(stu_choose!=5)
{
System.out.println("Choices of Students:(1-Add courses 2-Delete courses 3-Show Grades Chart 4-Search grades 5-Exit)\n");
stu_choose = sc.nextInt();
switch(stu_choose)
{
case 1:
System.out.println("Please enter the name of one course:\n");
sc.nextLine();
courses_name = sc.nextLine();
lec = new Lecture(courses_name, Integer.toString(0));
administrator.DeleteStudents(stu);
stu.Addlectures(lec);
administrator.StudentAdd(stu);
break;
case 2:
System.out.println("Please enter the name of one course:\n");
sc.nextLine();
courses_name = sc.nextLine();
lec = new Lecture(courses_name, Integer.toString(0));
administrator.DeleteStudents(stu);
stu.Deletelectures(lec);
administrator.StudentAdd(stu);
break;
case 3:
System.out.println("Your grades for all courses are as follows:\n");
i = 1;
stu.printgrades();
break;
case 4:
stu.searchgrades();
i = 1;
break;
default:
i = 1;
break;
}
}
}
}
}
}
}
}