Project2 :
Intro to OOP
Due: Feb 26th at 11:59pm
Summary: It is time to start object oriented programming.
Details:
Implement the 3 classes in the UML diagram above. More details are below.
You may add any additional *non-public*
methods that you want (including 'package protected'
The Child Class:
- Needs to have the five instance variables and one class/static
variable shown in the diagram
- nextID is the class variable.
- The constructor should take three
parameters.
- it must initialize the instance variable Name with the name param
- it must initialize the instance variable siblingInProgram with the
siblingPlan param
- it must initialize the instance variable age with the currentAge
param
- initialize the yearsOfAttendance instance variable to 0
- the dayCareID instance variable should be assigned the value of the
nextID static class variable
- the nextID class variable should be incremented.
- The CalculateBill method should
- charge according to the following schedule:
-
Age |
Rate |
birth to 1 year |
400 |
1-2 years |
300 |
3-4 years |
200 |
over 4 |
150 |
- If the child has a sibling in the program, give the child a
10% discount
- After the sibling discount, give the child an additional $10
discount for every year of attendance.
The DayCareWorker Class:
- Needs to have 3 instance variables as per the diagram
- The constructor should take two
parameters
- the Name instance variable should be initialized by the name
parameter
- the salary instance variable should be initialized by the
startingPay parameter
- thechildrenInGroup instance variable should be initialized to a new
ArrayList of Child (which is currently empty)
- The performanceReview method
- generate a random number from 1-5 (representing poor, below
expectations, meets expectations, exceeds expectations and
spectacular),
- based on the performance review, increase the salary of the
dayCareWorker
-
Review |
Salary increase |
poor (1) |
0% |
below Expectations(2) |
1% |
Meets Expectations(3) |
2.5% |
Exceeds Expectations (4) |
3.5% |
Spectacular (5) |
5% |
- The performFireDrill method
- loops through all of the children in the group and report (print)
that they are safe
- The getXXX methods
- accessor for the correct instance variable.
- the RemoveChild method
(note diagram incomplete!!!! the return type is Optional<Child>)
- look through the childrenInGroup list and find the child with the
matching id. remove the child from the childrenInGroup list and return
an Optional containing that child, if the child is not in the list
return an Optional of null.
The DayCareFacility Class:
- Needs two instance variables as specified in the diagram.
- The main function ( public
static void main)
- must only have two lines:
- create a new DayCareFacility Object
- call runDayCare on that object
- The constructor
- must initialize the two instance variables to new empty arrayLists
of the appropriate type
- The runDayCare
method:
- feel free to break this method into
pieces and make private methods to do parts of what is listed here.
(and just call those private methods from this one)
- needs to display the top level menu which should provide the
following options: (give visual feedback to the user for each)
- Admit Child
- prompt the user to enter the details you need
- create a new child object
- randomly select a dayCareWorker from the list to be the
worker assigned to that child.
- add the child to the list of children instance variable
- hire worker
- prompt the user to enter the details that you need
- create a new DayCareWorker object
- add the worker to the list of workers instance variable
- Students go to school
- all of the students who are 6 or older should be removed from
the system - both from the lists in the DayCareFacility and from
the DayCareWorkers lists
- RunFireDrill
- call the fireDrill method on each DayCareWorker
- exit
- end the program
- End of year:
- go through all the students and add one to their age and add one
to their years at the facility
- go through all of the DayCareWorkers and call their performance
review method
- DoAccounting
- run calculateBill on all the students and getSalary on all of
the workers and see of the facility is making or losing money (is
the total salary less or more than the total bills.) report this
to the user.
Have fun and learn a lot. This will take
some time, but each piece is fairly straightforward.
Additional Requirements:
- create a new project in intellij (don't submit a bunch of notes
and other extraneous files as part of the project)
- be sure to include your name in the project name somewhere.
- Start with one of the classes, and build it. Add it to git, and share
on github early and often I will look at the commit history. I am
looking for evidence that you committed a lot a small amount of credit
will be reserved for this
Submission:
Submit
by sharingthe project with me on github as you did last time.