diff options
author | Julian T <julian@jtle.dk> | 2020-09-03 10:40:36 +0200 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2020-09-03 11:22:28 +0200 |
commit | ba5f68924664b081aab1abb62c68e2fb70bdff0b (patch) | |
tree | e0efc49bcad596871c927b3649ef2efa57adb1d7 /sem5/oop/m1/src/Student.java | |
parent | 9ca3b52ba5cde24691b78f4c28b32897f133b259 (diff) |
Solve assignment /sem5/oop/m1 correctly
Diffstat (limited to 'sem5/oop/m1/src/Student.java')
-rw-r--r-- | sem5/oop/m1/src/Student.java | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/sem5/oop/m1/src/Student.java b/sem5/oop/m1/src/Student.java index cc9938c..2c1a5ae 100644 --- a/sem5/oop/m1/src/Student.java +++ b/sem5/oop/m1/src/Student.java @@ -3,20 +3,21 @@ public class Student extends Person implements Uniperson { private long semester; private String degree; - private double GPA; - private int GPAcount; + // 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.GPA = 0; - this.GPAcount = 0; + this.gradesum = 0; + this.gradecount = 0; } - public void addGPA(double GPA) { - this.GPA += GPA; - this.GPAcount++; + public void addGrade(double grade) { + this.gradesum += grade; + this.gradecount++; } public long getSem() { @@ -27,10 +28,10 @@ public class Student extends Person implements Uniperson { return this.degree; } - public double avgGPA() { - if (this.GPAcount == 0) { + public double getGPA() { + if (this.gradecount == 0) { return 0; } - return this.GPA / this.GPAcount; + return this.gradesum / this.gradecount; } } |