weight = 20
Assignment
For this lab, you will build on your Lab 9 solution to create a dog walking service that can track a sequence of days.
To do this, you must rename your DogWalkingService
class to ServiceDay
since it represents a day of the dog walking service.
You will create a new DogWalkingService
class that will contain an ArrayList
of ServiceDay
objects, one for each day the dog walking service is in business.
DogWalkingService |
-days: ArrayList<ServiceDay> |
+DogWalkingService(capacity: int) +enrollDog(dog: Dog): boolean +removeDog(index: int): Dog +processDay(numberOfWalks: int): void +getDaySummary(index: int): String +getDaySummary(): String +getSummary(): String |
Requirements for DogWalkingService
DogWalkingService(int capacity)
— Initializes thedays
list with oneServiceDay
object with the specified capacity.enrollDog(Dog dog)
— Adds a dog to theServiceDay
object at the end of thedays
list.removeDog(int index)
— Removes a dog from theServiceDay
object at the end of thedays
list.processDay(int numberOfWalks)
— conducts the specified number of walks on theServiceDay
object at the end of thedays
list. Whether the walk includes two dogs or all of the dogs should be determined at random with equal probability. After the walk(s) have been completed, a newServiceDay
object should be added to thedays
list with all the same dogs enrolled.getDaySummary(int day)
— Returns a summary of the ith day processed.getDaySummary()
— Returns a summary of the most recently processed day.getSummary()
— Returns a summary of all of the days processed.
Program
You must design the Lab10
class that is a program that:
- Asks the user how many dogs they would like to start with.
- Creates a
DogWalkingService
object that can support 25% more dogs than the user would like to walk. - Adds randomly named dogs to the
DogWalkingService
instance until there are as many dogs as the user wants to walk enrolled in the walking service. - Asks the user how many days they would like the service to run.
- Conducts the walks for the requested days using the following principles:
- There should be 2 to 6 walks (randomly determined) each day.
- Each walk should be between 10 and 45 minutes (randomly determined).
- Every third day, the dog that was enrolled the longest ago is removed from the current service day.
- Every fifth day, two additional dogs are enrolled in the current service day.
- Displays a summary of the results of all of the days processed.
The summary of the results of all of the days processed should be very similar to this:
The dog walking service was active for 12 days.
12% of the walks were successful (all dogs pooped)
Average number of walks per day: 3.3 walks
Average minutes per walk: 28.2 minutes
Average minutes per day: 93.0 minutes
Here is a summary of all 3 dogs still enrolled in the service:
1. Spot is a fast walker who peed 130 times and pooped 5 times.
2. Spotless is a slow walker who peed 98 times and pooped 1 time.
3. Yippee is a fast walker who peed 21 times and pooped 0 times.
Acknowledgement
This laboratory assignment was developed by Dr. Chris Taylor.
See your professor's instructions for details on submission guidelines and due dates.