Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class named DonorsList that has the following private fields: [ 1 Pt ] donatedOrgans ( ArryList of type DonatedOrgan class) avgAge ( double

Create a class named DonorsList that has the following private fields: [1 Pt]

  • donatedOrgans (ArryList of type DonatedOrgan class)
  • avgAge (double)

2. Provide a no-argument constructor to initialize the DonorsList object with an empty donatedOrgans ArrayList and avgAge set to 0.0. [1 Pt]

3. Provide setter and getter methods [1 Pt]

4. Override the toString() to return the String representation of the current object using the following format: [1.5 Pt]

Important Note 6: The String representation looks like:

Number of donated organs = 3

[DonatedOrgan(123, Upper Body, 13.445, 234, 25, Ahmed),

DonatedOrgan(234, Liver, 234.120, 234, 23, Fahd),

DonatedOrgan(983, Lung, 23.400 234, 44, Khaled)]

Average donor age = 30.666 years old

5. Add a method named addOrgan() that takes an input argument of type DonatedOrgan and adds it to the donatedOrgans list. The method must update the average age of the donors [2 Pt]

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

MySQL/PHP Database Applications

Authors: Jay Greenspan, Brad Bulger

1st Edition

978-0764535376

More Books

Students also viewed these Databases questions