Question: School class There is one instance variable for this class: a List of Person references. Use an initializer block to create an empty ArrayList and
School class
There is one instance variable for this class: a List of Person references.
Use an initializer block to create an empty ArrayList and assign it to your List variable.
public void registerPerson p: this method throws an IllegalPersonException if the argument is null. Otherwise, the Person is added to the end of your List.
public void printRoster: this method uses a method reference to print out all the people ie triggering a call to their respective toString methods
public void printAgesAndYears: this method declares a local variable w of type Writeable, which takes three parameters: fullName, yearBorn, and maxYear; for example: "Tiger Woods", or "Albert Einstein", It uses a lambda expression to loop through the integers from yearBorn to maxYear and prints the person's name and age for each year of life. For example use all the years; some were omitted here for brevity:
Tiger Woods: age
Tiger Woods: age
Tiger Woods: age
Tiger Woods: age
Tiger Woods: age
Tiger Woods: age
etc
Tiger Woods: age
Tiger Woods: age
Tiger Woods: age
Tiger Woods: age if the Person is alive, loop until the current year
Finally, loop through your List of Person references and use a lambda expression to determine the argument values to pass to ws printData method fullName, yearBorn, and maxYear as follows:
fullName: the Person's getNamegetPrettyName
yearBorn: the Person's getDateOfBirthgetYear
maxYear: the current year if alive or the Person's getDateOfDeathgetYearif not alive
Albert Einstein: age
Albert Einstein: age
Albert Einstein: age
Albert Einstein: age
etc
Albert Einstein: age
Albert Einstein: age
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
