This assignment reviews the coding techniques and concepts that should already be familiar to you from COMP 132 or equivalent courses. If this material is new to you or is very difficult, you should not be taking this course. If this material is familiar but a little difficult, you're in the right place!
Topics covered by this lab include:
Do not add any public fields or methods to the classes in this assignment beyond those listed in the UML. However, you may add as many private fields and methods as you see fit.
Create the Person class as described below.
Each Person should be assigned a unique ID value when created, starting from 1 for the first instance, and increasing by 1 for each subsequent instance.
The givenName and surname properties store this person's personal and family names respectively (eg. "George" and "Smith"). Either of these fields may be left blank (null).
The toString() method should return a String displaying the person's full name and ID, for example "John Jones (ID# 0003)". If a name field is null, it should not be included in the output.
Remember to use JavaDoc to document all public fields, constructors, and methods!
Create the Employee, Nurse, Doctor, and Patient classes described below.
The unit property describes the area or department where an employee works, for example: "Emergency", "Human Resources", or "Radiology".
The annualSalary field records this employee's base annual earnings, in dollars. It should be set to an appropriate amount by every subclass. The getAnnualSalary() method should return this amount.
Nurses are assigned a shift number that indicates the time of day and number of hours that they work. The default shift for new instances is SHIFT_A.
Nurses have a default annual salary of $80,000. However, if assigned to SHIFT_B they will earn $85,000 and if assigned to SHIFT_C they will earn $90,000.
The toString() method should be overridden by this class to include the nurse's unit and assigned shift number (eg. "Martha McGee (ID# 1234) (Radiology unit, shift 5)").
The specialty field describes this doctor's main area of medicine, such as "Family Practice", "Neurology", or "Surgury".
All doctors earn an annual salary of $250,000.
The toString() method should be overridden by this class to prefix the doctor's name with "Dr." and include their specialty (eg. "Dr. Brenda Freeman (ID# 0023) (Podiatry)").
Every patient must be assigned a physician who is the Doctor primarily responsible for their care.
The Patient class does not override the toString() method that it inherits from Person.
Create a main program class that:
Nurse instances assigned to different shifts.Doctor instances.Patient instances with pre-determined names and manually assigned physicians chosen from the pool of Doctor instances previously created.Patient instances using randomly generated names and randomly assigns them physicians chosen from the pool of Doctor instances previously created.toString() values for all employees.toString() value and physician ID for each patient.Use arrays to store all of your Patient, Nurse, and Doctor objects.
You can generate names by randomly choosing a combination of first and last names from pre-set lists of possibilities.
// source: https://nameberry.com/unisex-names
String[] givenNames = {
"Avery", "Riley", "Jordan", "Angel", "Peyton",
"Quinn", "Hayden", "Taylor", "Alexis", "Rowan",
"Charlie", "Emerson", "Finley", "River", "Emery",
"Morgan", "Elliot", "London", "Eden", "Elliott",
"Karter", "Dakota", "Reese", "Remington", "Payton",
"Amari", "Phoenix", "Kendall", "Harley", "Rylan",
"Marley", "Dallas", "Skyler", "Spencer", "Sage",
"Kyrie", "Ellis", "Rory", "Remi", "Justice",
"Ali", "Haven", "Tatum", "Arden", "Linden",
"Devon", "Rebel", "Rio", "Ripley", "Frankie"
};
// source: http://www.locatemyname.com/topsurnames.php?country=canada
String[] surnames = {
"Smith", "Brown", "Tremblay", "Martin", "Roy",
"Wilson", "Macdonald", "Gagnon", "Johnson", "Taylor",
"Cote", "Campbell", "Anderson", "Leblanc", "Lee",
"Jones", "White", "Williams", "Miller", "Thompson",
"Gauthier", "Young", "Van", "Morin", "Bouchard",
"Scott", "Stewart", "Belanger", "Reid", "Pelletier",
"Moore", "Lavoie", "King", "Robinson", "Levesque",
"Murphy", "Fortin", "Gagne", "Wong", "Clark",
"Johnston", "Clarke", "Ross", "Walker", "Thomas",
"Boucher", "Landry", "Kelly", "Bergeron", "Davis"
};
Do not use input from System.in for any part of your program.
Use static methods as appropriate to organize your code.
Try to keep all output at the end of your program.
Completing all tasks in this lab should result in 6 separate Java files within a single package named like LastnameFirstname_lab1. Compress the package directory into a ZIP archive and upload it to the D2L assignment.
The marks for this lab are heavily weighted towards good coding practice and style. Pay attention to your code formatting, make sure you have documented all public members using JavaDoc, and make sure you are using constants, arrays, loops, and methods effectively.
NOTE: This assignment is to be done individually. You can help one another with problems and questions, but in the end everyone must do their own work.
| Criteria | Marks |
|---|---|
| Programs compile and run without error | 2 |
| Good coding style | 2 |
| Task requirements met or exceeded | 2 |
| Total | 6 |