aboutsummaryrefslogtreecommitdiff
path: root/sem5/oop/m1/src/Student.java
diff options
context:
space:
mode:
Diffstat (limited to 'sem5/oop/m1/src/Student.java')
-rw-r--r--sem5/oop/m1/src/Student.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/sem5/oop/m1/src/Student.java b/sem5/oop/m1/src/Student.java
new file mode 100644
index 0000000..cc9938c
--- /dev/null
+++ b/sem5/oop/m1/src/Student.java
@@ -0,0 +1,36 @@
+public class Student extends Person implements Uniperson {
+ // Yes, we do support very long educations
+ private long semester;
+ private String degree;
+
+ private double GPA;
+ private int GPAcount;
+
+ 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;
+ }
+
+ public void addGPA(double GPA) {
+ this.GPA += GPA;
+ this.GPAcount++;
+ }
+
+ public long getSem() {
+ return this.semester;
+ }
+
+ public String getDeg() {
+ return this.degree;
+ }
+
+ public double avgGPA() {
+ if (this.GPAcount == 0) {
+ return 0;
+ }
+ return this.GPA / this.GPAcount;
+ }
+}