-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMathsStudent.java
More file actions
42 lines (37 loc) · 1023 Bytes
/
MathsStudent.java
File metadata and controls
42 lines (37 loc) · 1023 Bytes
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
public class MathsStudent {
private String name;
private char grade;
private int group;
private String secretNickName = "MySecretNickName";
private static char MAX_GRADE = 'A';
private static char MIN_GRADE = 'F';
private static int MAX_GROUP_VALUE = 5;
private static int MIN_GROUP_VALUE = 1;
public MathsStudent(String name, char grade, int group) {
GroupValueCheck(group);
this.name = name;
this.grade = grade;
this.group = group;
}
void GroupValueCheck(int group) {
if ((group < MIN_GROUP_VALUE) || (group > MAX_GROUP_VALUE) )
throw new IllegalArgumentException();
}
public String getName() {
return name;
}
public char getGrade(){
return grade;
}
public void upgrade() {
if (grade != MAX_GRADE)
grade--;
}
public void downgrade() {
if (grade != MIN_GRADE)
grade++;
}
public int getGroup() {
return group;
}
}