Question: Phase 3: Patients Next, implement the Patient class. The Patient class should have: Two instance variables: the patients name (a String ), and a list

Phase 3: Patients

Next, implement the Patient class.

The Patient class should have:

Two instance variables: the patients name (a String), and a list of all of this patients prescriptions (a MedicineList).

This time, there will be no separate PatientList class. Instead, provide class (static) variables that will keep track of all of the Patient objects that have ever been created. Allow for up to 100 Patient objects. Use a simple partially-full array to do this. You may assume that the list will never become full no error checking is needed.

A constructor with a single String parameter giving the patients name.

A method void prescribe(Medicine) which will add a medicine to this patients list of prescriptions.

A standard toString method which will return a String containing the patients name followed by a list of prescriptions, in parentheses. See the sample output below.

A class (static) method void listAllPatients() which will print a list of all of the patients that have been created, using the toString format. (This one can contain a println statement to produce output.)

You can test your class using the supplied test program TestPhase3.java. You should get the same output as you did for Phase 2, plus the following additional output:

Patients

--------

Arthur (ExxoPlexx,MiracleCure,Hydramax)

Betty (TastyPill,MiracleCure)

Chris (Hydramax)

Don (ExxoPlexx,Hydramax,TastyPill)

Eddie (Buyalot,Hydramax,TastyPill)

Fran (ExxoPlexx,Hydramax)

George (ExxoPlexx,Buyalot,TastyPill)

Helen ()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!