aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sem5/oop/m1/src/Main.java6
-rw-r--r--sem5/oop/m1/src/Student.java21
-rw-r--r--sem5/oop/m1/src/Uniperson.java4
3 files changed, 16 insertions, 15 deletions
diff --git a/sem5/oop/m1/src/Main.java b/sem5/oop/m1/src/Main.java
index 4ccb5a4..b7c1f42 100644
--- a/sem5/oop/m1/src/Main.java
+++ b/sem5/oop/m1/src/Main.java
@@ -4,10 +4,10 @@ public class Main {
Student std = new Student("Julian", (short)21, "Male", (long)123213213, "COMTEK");
Uniperson hej = std;
- hej.addGPA(0.32);
- hej.addGPA(12);
+ hej.addGrade(0.32);
+ hej.addGrade(12);
- System.out.printf("deg: %s, sem: %d, avg: %f\n", hej.getDeg(), hej.getSem(), hej.avgGPA());
+ System.out.printf("deg: %s, sem: %d, avg: %f\n", hej.getDeg(), hej.getSem(), hej.getGPA());
System.out.printf("person: %s\n", std);
}
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;
}
}
diff --git a/sem5/oop/m1/src/Uniperson.java b/sem5/oop/m1/src/Uniperson.java
index 7493dea..ccde0df 100644
--- a/sem5/oop/m1/src/Uniperson.java
+++ b/sem5/oop/m1/src/Uniperson.java
@@ -2,6 +2,6 @@
public interface Uniperson {
public long getSem();
public String getDeg();
- public double avgGPA();
- public void addGPA(double GPA);
+ public double getGPA();
+ public void addGrade(double grade);
}