-
Notifications
You must be signed in to change notification settings - Fork 3
/
Student.java
108 lines (99 loc) · 2.2 KB
/
Student.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
import javax.swing.*;
import java.util.*;
public class Student{
String name;
String id;
String classes;
List<Lecture> StudentLectures;
public Student(String name, String id, String classes)
{
this.name = name;
this.id = id;
this.classes = classes;
StudentLectures = new LinkedList<Lecture>();
}
public String getName()
{
return name;
}
public String getid()
{
return id;
}
public String getclass()
{
return classes;
}
public List getlectures()
{
return StudentLectures;
}
public void Addlectures(Lecture lec)
{
int contained = 0;
for(int i=0; i<StudentLectures.size(); i++)
{
if((lec.getlecname()).equals((StudentLectures.get(i)).getlecname()))
{
contained = 1;
break;
}
}
if(contained != 1)
StudentLectures.add(lec);
}
public void Deletelectures(Lecture lec)
{
int selected = -1;
for(int i=0; i<StudentLectures.size(); i++)
{
if((lec.getlecname()).equals((StudentLectures.get(i)).getlecname()))
{
selected = i;
break;
}
}
if(selected != -1)
StudentLectures.remove(selected);
}
public void printgrades()
{
if(StudentLectures.size() > 0)
{
for(int i=0; i<StudentLectures.size(); i++)
{
System.out.println((StudentLectures.get(i)).getlecname() + ": ");
System.out.println((StudentLectures.get(i)).getgrades() + "\n");
}
}
}
public void inputgrades(String grades, String lecname)
{
for(int i = 0; i < StudentLectures.size(); i++)
{
if(lecname.equals((StudentLectures.get(i)).getlecname()))
{
(StudentLectures.get(i)).entergrades(grades);
break;
}
}
}
public void searchgrades()
{
Scanner sc = new Scanner(System.in);
System.out.println("Lecture Name:");
String lecname = sc.nextLine();
int find = -1;
for(int i=0; i<StudentLectures.size(); i++)
{
if(lecname.equals((StudentLectures.get(i)).getlecname()))
{
find = 1;
System.out.println("Grades: ");
System.out.println(((StudentLectures.get(i)).getgrades()) + "\n");
}
}
if(find == -1)
System.out.println("No such lecture, no grades!");
}
}