Create a reference data type using the following criteria Pr
Create a reference data type using the following criteria.
Problem statement:
Create a reference data type that will be used by a college to store a persons
information. The information that needs to be stored are the persons name,
current address, permanent address, id number, date of birth, current age, year
the person entered the college system, and how long the person has been with
the college. Rather than ask for the current age, calculate it using the persons
date of birth and current year. Rather than ask for how long the user has been with
the college, calculate it using by using the year the person first entered the system
and the current year.
In your Person class:Add mutator methods for each field.
Do not use Scanner in the Person class.
All values will be passed in via parameters.
Add accessor methods for each field.
Add a toString() method.
Include all fields.
Include a message with each field so the user knows what they are looking at.
Format the string using the new line escape sequence \ so that each field and it\'s message is on a separate line.
In your test class:For the first object:
Use Scanner to collect values for each field from the user.
Include a prompt with each input telling the user what the input is for.
Call the appropriate mutator function to set the value.
Call the appropriate accessor function to display the value.
After all input has been collected, call the toString() method to display all of the values.
For the second object:
Use Scanner to collect values for each field from the user except id number. The id number should be set in the constructor.
Include a prompt with each input telling the user what the input is for.
Call the appropriate mutator function to set the value.
Call the appropriate accessor function to display the value.
After all input has been collected, call the toString() method to display all of the values.
Solution
class Persons_Information {
private String personName;
private String currentAdress;
private String permanentAdress;
private int idNumber;
private String birthDate;
private int personAge;
private int entryYear;
private int totalYears;
public Persons_Information() {
personName = \"\";
currentAdress = \"\";
permanentAdress = \"\";
idNumber = 0;
birthDate = \"\";
personAge = 0;
entryYear = 0;
totalYears = 0;
}
public Persons_Information (int atIdNumber) {
idNumber = atIdNumber;
personName = \"\";
currentAdress = \"\";
permanentAdress = \"\";
birthDate = \"\";
personAge = 0;
entryYear = 0;
totalYears = 0;
}
//intput
public void setPersonName(String personName) {
this.personName = personName;
}
public void setCurrentAdress(String currentAdress) {
this.currentAdress = currentAdress;
}
public void setpermanentAdress(string permanentAdress) {
this.permanentAdress = permanentAdress;
}
public void setIdNumber(int id) {
idNumber = id;
}
public void setBirthDate(String birthDate) {
this.birthDate = birthDate;
}
public void setPersonAge(int pa) {
personAge = pa;
}
public void setEntryYear(int ey) {
entryYear = ey;
}
public void setTotalYears(int ty) {
totalYears = ty;
}
//output
public String getPersonName() {
return personName;
}
public String getCurrentAdress() {
return currentAdresss;
}
public String getPermanentAdress() {
return permanentAdress;
}
public int getIdNumber() {
return idNumber;
}
public String getBirthDate() {
return birthDate;
}
public int getPersonAge() {
return personAge;
}
public int getEntryYear() {
return entryYear;
}
public int getTotalYears() {
return totalears;
}
//toString
public String toString(){
return \"Name:\" + personName +
\"Current Adress:\" + currentAdress +
\"Permanent Adress:\" + permanentAdress +
\"ID Number:\" + idNumber +
\"Birth Date\" + birthDate +
\"Age:\" + personAge +
\"Entry Year:\" + entryYear +
\"Total Years in System:\" + totalYear +
}
}




