-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.java
More file actions
65 lines (54 loc) · 1.89 KB
/
Copy pathStudent.java
File metadata and controls
65 lines (54 loc) · 1.89 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* CSC 152 Program Assignment 2 – Inheritance, Spring 2020 - section
* FileName: Student
* Purpose: Pratice concepts of chapter 10 and 7
* Name: Can Dilikoglu
* Major: Computer Science
*/
public class Student extends Person
{
private String major = "Undeclared"; // to hold value of major
private String minor = "No Minor"; // to hold value of minor
private double gpa = 0.00; // to hold value of gpa
public Student(String firstName, String lastName, int bYear, double money) // constructor, has 4 parameters
{ super(firstName,lastName,bYear,money); // super method
major = "Undeclared";
minor = "No Minor";
gpa = 0.00;
}
public Student(String firstName, String lastName, int bYear, double money, String major, double gpa) // constructor, has 6 parameters
{ super(firstName,lastName,bYear,money); // super method
this.major = major; // used "this" method to avoid shadowing
this.gpa = gpa; // used "this" method to avoid shadowing
minor = "No Minor";
}
public String getMajor() // returns the value of major
{ return major;
}
public void switchMajor(String newMajor) // changes the value of major
{ major = newMajor;
}
public String getMinor() // returns the value of minor
{ return minor;
}
public void changeMinor(String newMinor) // changes the value of minor
{ minor = newMinor;
}
public double getGPA() // returns the value of gpa
{ return gpa;
}
public void setGPA(double newGPA) // changes the value of gpa
{ gpa = newGPA;
}
public String toString() // toString method to display all of the attributes of a student object
{ String str = super.toString()+"\t\t";
if(major.equals("Undeclared"))
str+="n/a"+"\t"+minor+"\t"+gpa;
else
str+=major+"\t"+minor+"\t"+gpa;
return str;
}
/* CSC 152 Program Assignment 2 – Inheritance, Spring 2020 - section
* This file Student is created by Can Dilikoglu, 00463308
*/
}