Question: Hello, My answer does not work what should I have to add here? package academicsystem; import java.time.LocalDate; import java.time.Month; import java.util.ArrayList; class Student { private

Hello, My answer does not work what should I have to add here?

package academicsystem;

import java.time.LocalDate;

import java.time.Month;

import java.util.ArrayList;

class Student {

private String firstname;

private String lastname;

private String street;

private String place;

private String zip;

private String address;

private int sno;

private LocalDate dob;

private LocalDate doj;

public Student(String firstname, String lastname, String street, String place, String zip, String address, int sno, LocalDate doj, LocalDate dob) {

this.firstname = firstname;

this.lastname = lastname;

this.street = street;

this.place = place;

this.zip = zip;

this.address = address;

this.sno = sno;

this.dob = dob;

this.doj = doj;

if(getStudentAge()>100){

throw new IllegalArgumentException("Please check the year entered, student cannot be over 100 years old");

}

}

// function to collate and return address

public String getStudentAddress() {

return street+" "+place+" "+zip;

}

// set new address

public void changeAddress(String street, String place, String zip) {

this.street = street;

this.place = place;

this.zip = zip;

}

// print student name and number when student object is printed

public String toString(){

return firstname+" "+lastname+", student number: "+sno;

}

public int getStudentAge(){

return LocalDate.now().getYear()-dob.getYear();

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!