-
Notifications
You must be signed in to change notification settings - Fork 0
/
Student.java
75 lines (65 loc) · 1.39 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
import java.util.Arrays;
public class Student {
private String name;
private int age;
private int[] marks;
private EFaculty faculty;
public Student(String name, int age, int[] marks, EFaculty faculty) {
super();
this.name = name;
this.age = age;
this.marks = marks;
this.faculty = faculty;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) throws ExceptionInputAge {
if(age>=18 && age<=65)
this.age = age;
else
throw new ExceptionInputAge();
}
public int[] getMarks() {
return marks;
}
public void setMarks(int[] marks) {
this.marks = marks;
}
public EFaculty getFaculty() {
return faculty;
}
public void setFaculty(EFaculty faculty) {
this.faculty = faculty;
}
@Override
public String toString() {
return "Student [name=" + name + ", age=" + age + ", marks=" + Arrays.toString(marks) + ", faculty=" + faculty
+ "]";
}
public int maxMark() {
int max=marks[0];
for(int i=0; i<marks.length; i++)
if(marks[i]>max)
max= marks[i];
return max;
}
//used for testing the cross-check
public int maxMark2() {
int aux;
for(int i=0; i<marks.length; i++)
for(int j=i+1; j<marks.length; j++)
if(marks[i]<marks[j]) {
aux=marks[i];
marks[i]=marks[j];
marks[j]=aux;
}
return marks[0];
}
}