Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class named Organ with the following private instance and class fields: [ 0.5 Pt ] serial ( int ) : Cannot be negative

Create a class named Organ with the following private instance and class fields: [0.5 Pt]

  • serial (int) : Cannot be negative
  • type (String) : Cannot be null
  • density (double) : Cannot be negative
  • total (int) to keep track of the total number of Organ objects created.

2. Provide a full-argument constructor [1 Pt]

Important Note 2: Make sure to validate the input arguments.

3. Provide a no-argument constructor [0.25 Pt]

Important Note 3: Make sure to call the full-argument constructor

4. Provide a copy constructor [0.5 Pt]

Important Note 4: Make sure that the input argument is not null by calling Objects.requireNonNull() method

5. Provide setter and getter methods [1 Pt]

Important Note 5: Make sure to validate the input arguments of each setter method.

6. Override the toString() to return the String representation of the current object [1 Pt]

Important Note 6: The String representation looks like:

Organ(123, Upper Body, 13.445, 234)

when serial = 123, type = Upper Body, serial = 13.445, and there are 234 Organ objects created. Floating-point numbers are formatted using 3 decimals.

Part II:

1. Create a class named DonatedOrgan that extends the Organ class. The DonatedOrgan class defines two private fields: [0.5 Pt]

  • donor_age (int) : Cannot be negative
  • donor_name (String) : Cannot be null

2. Provide a full-argument constructor [1 Pt]

Important Note 1: Make sure to validate the input arguments.

3. Provide setter and getter methods [1 Pt]

Important Note 2: Make sure to validate the input arguments of each setter method.

4. Override the toString() to return the String representation of the current object. Your implementation must call the toString() method of the Organ class [1 Pt]

Important Note 4: The String representation looks like:

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

when serial = 123, type = Upper Body, serial = 13.445, age = 25, name = Ahmed, and there are 234 DonatedOrgan objects created. Floating-point numbers are formatted using 3 decimals.

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

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions

Question

Discuss the various types of leasing.

Answered: 1 week ago

Question

Define the term "Leasing"

Answered: 1 week ago

Question

What do you mean by Dividend ?

Answered: 1 week ago

Question

What is database?

Answered: 1 week ago