Java Reference
In-Depth Information
//Constructor with parameters
//Instance variables are set according to the parameters
//Postcondition: firstName = first; lastName = last;
// dMonth = month; dDay = day; dYear = year;
// personID = ID;
public PersonalInfo(String first, String last, int month,
int day, int year, int ID)
{
name = new Person(first, last); //instantiate and
//initialize the object name
bDay = new Date(month, day, year); //instantiate and
//initialize the object bDay
personID = ID;
}
//Method to set the personal information
//Instance variables are set according to the parameters
//Postcondition: firstName = first; lastName = last;
// dMonth = month; dDay = day; dYear = year;
// personID = ID;
public void setPersonalInfo(String first, String last, int month,
int day, int year, int ID)
{
name.setName(first, last);
bDay.setDate(month, day, year);
personID = ID;
}
//Method to return the string containing personal information
public String toString()
{
return ("Name: " + name.toString() + "\n"
+ "Date of birth: " + bDay.toString() + "\n"
+ "Personal ID: " + personID);
1
0
}
}
The definitions of the class es Person , Date , and PersonalInfo , as well as a
program that shows how to use these classes can be found in the Additional Student Files
folder at www.cengagebrain.com. The folder Composition contains the necessary files.
 
Search WWH ::




Custom Search