-
Notifications
You must be signed in to change notification settings - Fork 0
/
Student.java
85 lines (80 loc) · 2.57 KB
/
Student.java
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package assignment1;
/**
*
* @author shuxiang
*/
import java.time.LocalDate;
import java.time.Period;
public class Student extends Person{
private String major;
private int studentNumber;
private LocalDate enrollementDate;
private boolean inGoodStanding;
public Student(String FN, String LN, String SA, String C, String P, String PC, LocalDate BD,
String M, int SN, LocalDate ED) {
super(FN, LN, SA, C, P, PC, BD);
this.major=M;
this.studentNumber=SN;
this.enrollementDate=ED;
this.inGoodStanding = true;
}
public void setMajor(String M){
this.major=M;
}
public void setStudentNumber(int SN){
if (SN > 0){
this.studentNumber = SN;
}else{
throw new IllegalArgumentException("Student number cannot be 0, it should have 9 digits");}
}
public void setInGoodStanding(Boolean inGoodStanding) {
this.inGoodStanding = inGoodStanding;
}
public void suspendStudent() {
inGoodStanding = false;
}
public void reinstateStudent() {
inGoodStanding = true;
}
public void setEnrollementDate(LocalDate ED){
this.enrollementDate=ED;
}
public void setBirthday(LocalDate BD){
LocalDate today = LocalDate.now();
int age = Period.between(BD, today).getYears();
if (age > 14 || age < 90){
this.birthDate = BD;
}else{
throw new IllegalArgumentException("Must be between 14-90");}
}
public int getYearEnrolled(){
return enrollementDate.getYear();
}
public int getYearsAtCollege()
{
int YearsAtCollege = LocalDate.now().getYear() - enrollementDate.getYear();
if (YearsAtCollege <= 0)
throw new IllegalArgumentException("Must be more than 0!");
return YearsAtCollege;
}
public Boolean inGoodStanding()
{
if (inGoodStanding == true){
return true;}else{
return false;}
}
public String getMajor() {
return major;
}
public int getStudentNumber() {
return studentNumber;
}
public String toString() {
return getFirsName()+ " " + getLastName() + ", student number is " + this.studentNumber;
}
}