Overview

For this lab, you will revise your Lab 8 solution by introducing arrays of Dogs in the DogWalkingService class.

Assignment

The previous version of the DogWalkingService class you implemented was limited in that you could only walk three dogs. Things have been going great, and you've decided to open a business and handle more than three dogs.

The following diagram shows the revised API that you are to implement. Detail on each change is given below.

Dog
-name: String {readOnly}
-prefersFastWalks: boolean {readOnly}
-solidProductionRate: int {readOnly}
-totalWalks: int
-totalTimesPeed: int
-totalTimesPooped: int
+DOG_NAMES: String[] = {"Spot", "Spotless", "Yippee", ...} {readOnly}
+Dog()
+Dog(name: String)
+Dog(name: String, prefersFastWalks: boolean, solidProductionRate: int)
+getName(): String
+walk(lengthInMinutes: int, isFast: boolean): boolean
+getNumberOfWalks(): int
+getTotalTimesPeed(): int
+getTotalTimesPooped(): int
+toString(): String
-makePluralIfAppropriate(quantity: int, word: String): String

Changes to Dog

You will need to make the following changes to your Dog class:

DogWalkingService
-dogs: Dog[] {readOnly}
-numberOfDogs: int
-dog1: Dog {readOnly}
-dog2: Dog {readOnly}
-dog3: Dog {readOnly}
-successCount: int
-numberOfWalks: int
-totalMinutes: int
+DogWalkingService(dog1: Dog, dog2: Dog, dog3: Dog)
+DogWalkingService(capacity: int)
+enrollDog(dog: Dog): boolean
+removeDog(index: int): Dog
+getSummary(): String
+walk2Dogs(minutes: int): boolean
+walk2Dogs(minutes: int, isFast: boolean): boolean
+walkAllDogs(minutes: int): boolean
+walkAllDogs(minutes: int, isFast: boolean): boolean
+getNumberOfWalks(): int
+getTotalMinutesWalked(): int
+getNumberOfSuccessfulWalks(): int
+getDogs(): Dog[]
+getNumberOfDogs(): int
+getSpacesLeft(): int

Changes to DogWalkingService

The dogs array is used to keep track of all the dogs managed by the dog walking service. The dogs should be added to the array from left to right. For example, if there are two dogs being managed by the service, they should be stored in index 0 and 1 of the dogs array.

You will need to make the following changes to your DogWalkingService class:

Program

You must design the Lab9 class that is a program that:

  1. Asks the user how many dogs they would like to walk.
  2. Creates a DogWalkingService object that can support 25% more dogs than the user would like to walk.
  3. 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.
  4. Asks the user how many walks they would like to take today.
  5. Conducts the walks.
  6. Displays a summary of the results.

Acknowledgement

This laboratory assignment was developed by Dr. Chris Taylor.

See your professor's instructions for details on submission guidelines and due dates.