forked from OneThousandDong/Int2204-9
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudentManagement.java
89 lines (82 loc) · 2.24 KB
/
studentManagement.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
import java.util.*;
public class studentManagement {
public student [] sv=new student[100];
private int size=0;
public boolean arrayStudent(student s)
{
if(size==100)
{
return false;
}
sv[size]=s;
size++;
return true;
}
public boolean sameGroup(student s1,student s2)
{
return s1.getGroup().equals(s2.getGroup());
}
public void removeStudent(String id)
{
for(int i=0;i<size;i++)
{
if(sv[i].getId().equals(id))
{
sv[i]=sv[i+1];
size--;
}
}
}
public void studentsByGroup()
{
List<String> clas = new ArrayList ();
for (int i = 0; i < size; i++)
{
if (!clas.contains(sv[i].getGroup()))
{
clas.add(sv[i].getGroup());
}
}
for (int i = 0; i < clas.size(); i++)
{
System.out.println("Group: " + clas.get(i));
for (int j = 0; j < size; j++)
{
if ( sv[j].getGroup().equals(clas.get(i)))
System.out.println(sv[j].getInfo());
}
System.out.println();
}
}
public static void main(String[] args) {
studentManagement sm=new studentManagement ();
student s1=new student("lien"," 17020850","k62","[email protected]");
System.out.println(s1.getName());
System.out.println(s1.getInfo());
student s2=new student("an","001","k62","em");
student s3=new student ("chi","002","k63","k63");
student s4=new student("k64");
if(sm.sameGroup(s1,s2))
{
System.out.println("YES");
}
else
{
System.out.println("NO");
}
if(sm.sameGroup(s1,s3))
{
System.out.println("YES");
}
else
{
System.out.println("NO");
}
sm.arrayStudent(s1);
sm.arrayStudent(s2);
sm.arrayStudent(s3);
//sm.removeStudent("001");
sm.studentsByGroup();
//System.out.println(sm.size);
}
}