aboutsummaryrefslogtreecommitdiff
path: root/sem5/oop/m1/src/Student.java
blob: 2c1a5ae39a2281fbcee7293272bb5927504c1014 (plain)
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
public class Student extends Person implements Uniperson {
	// Yes, we do support very long educations
	private long semester;
	private String degree;

	// GPA stuff
	private double gradesum;
	private int gradecount;
	
	public Student(String name, short age, String gender, long semester, String degree) {
		super(name, gender, age);
		this.semester = semester;
		this.degree = degree;
		this.gradesum = 0;
		this.gradecount = 0;
	}
	
	public void addGrade(double grade) {
		this.gradesum += grade;
		this.gradecount++;
	}

	public long getSem() {
		return this.semester;
	}
	
	public String getDeg() {
		return this.degree;
	}
	
	public double getGPA() {
		if (this.gradecount == 0) {
			return 0;
		}
		return this.gradesum / this.gradecount;
	}
}