From ba5f68924664b081aab1abb62c68e2fb70bdff0b Mon Sep 17 00:00:00 2001 From: Julian T Date: Thu, 3 Sep 2020 10:40:36 +0200 Subject: Solve assignment /sem5/oop/m1 correctly --- sem5/oop/m1/src/Student.java | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'sem5/oop/m1/src/Student.java') 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; } } -- cgit v1.2.3