Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started