-
Notifications
You must be signed in to change notification settings - Fork 0
/
StudentManagement.java
71 lines (65 loc) · 2.12 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
import java.util.ArrayList;
public class StudentManagement
{
public ArrayList<Student> std = new ArrayList<Student>(100);
public void removeStudent(String id)
{
for (int i = 0; i < std.size(); i++)
{
Student stud = std.get(i);
if (stud.getId().equals(id))
std.remove(i);
}
}
public void studentByGroup()
{
Student tem = std.get(0);
String presentGroup = tem.getGroup();
String nextGroup = "";
int size = std.size();
boolean[] check = new boolean[size];
for (int i = 0; i < size; i++)
{
Student temStudent = std.get(i);
if (check[i] != true)
{
if (temStudent.getGroup().equals(presentGroup))
{
System.out.println(temStudent.getInfo());
check[i] = true;
}
else
{
nextGroup = temStudent.getGroup();
}
if (i == size - 1)
{
i = 0;
presentGroup = nextGroup;
}
}
}
}
public boolean sameGroup(Student s1, Student s2)
{
return s1.getGroup().equals(s2.getGroup());
}
public static void main(String[] args)
{
Student st1 = new Student();
st1.setName("Trịnh Thị Thảo");
st1.setId("17021025");
st1.setGroup("INT22041");
st1.setEmail("[email protected]");
System.out.println("Name: " + st1.getName());
System.out.println("Thong tin: " + st1.getInfo());
Student st2 = new Student();
System.out.println(st2.getInfo());
Student st3 = new Student("Thảo Ngọc", "1700000", "[email protected]");
System.out.println(st3.getInfo());
Student st4 = new Student(st3);
System.out.println(st4.getInfo());
StudentManagement sm = new StudentManagement();
System.out.println(sm.sameGroup(st1, st2));
}
}