Answered step by step
Verified Expert Solution
Link Copied!

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 register(Person 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 (i.e. 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", 1975,2022, or "Albert Einstein", 1879,1955. 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: 1975(age 0)
Tiger Woods: 1976(age 1)
Tiger Woods: 1977(age 2)
Tiger Woods: 1978(age 3)
Tiger Woods: 1979(age 4)
Tiger Woods: 1980(age 5)
... etc ...
Tiger Woods: 2019(age 44)
Tiger Woods: 2020(age 45)
Tiger Woods: 2021(age 46)
Tiger Woods: 2022(age 47)// 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 w's printData() method - fullName, yearBorn, and maxYear as follows:
1. fullName: the Person's getName().getPrettyName()
2. yearBorn: the Person's getDateOfBirth().getYear()
3. maxYear: the current year (if alive), or the Person's getDateOfDeath().getYear()(if not alive).
Albert Einstein: 1879(age 0)
Albert Einstein: 1880(age 1)
Albert Einstein: 1881(age 2)
Albert Einstein: 1882(age 3)
... etc ...
Albert Einstein: 1953(age 74)
Albert Einstein: 1954(age 75)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Design A Practical Approach

Authors: Marilyn Campbell

1st Edition

1587193175, 978-1587193170

More Books

Students also viewed these Databases questions

Question

What is the environment we are trying to create?

Answered: 1 week ago

Question

How can we visually describe our goals?

Answered: 1 week ago