2025 AP Computer Science A FRQ #1A

Write the walkDogs method, which updates and returns the number of dogs this dog walker walks during the time specified by hour. Values of hour range from 0 to 23, inclusive. A helper method, numAvailableDogs, has been provided in the DogWalkCompany class. The method returns the number of dogs available to be taken for a walk at a given hour. The dog walker will always walk as many dogs as the dog-walking company has available to walk, as long as the available number of dogs is not greater than the maximum number of dogs that the dog walker can handle, represented by the value of maxDogs. Another helper method, updateDogs, has also been provided in the DogWalkCompany class. So that multiple dog walkers do not sign up to walk the same dogs, the walkDogs method should use updateDogs to update the dog-walking company with the number of dogs this dog walker will walk during the given hour. The parameters of the updateDogs method indicate how many dogs this dog walker will walk during the time specified by hour. For example, if the dog-walking company has 10 dogs that need to be walked at the given hour but the dog walker’s maximum is 4, the updateDogs method should be used to indicate that this dog walker will walk 4 of the 10 dogs during the given hour. As another example, if the dog-walking company has 3 dogs that need to be walked at the given hour and the dog walker’s maximum is 4, the updateDogs method should be used to indicate that this dog walker will walk all 3 of the available dogs during the given hour. The walkDogs method should return the number of dogs to be walked by this dog walker during the time specified by hour. Complete method walkDogs. You must use numAvailableDogs and updateDogs appropriately to receive full credit. Intro: 00:00 Writing the pseudocode: 02:18 Writing the code: 03:42 Testing the code: 06:50 Final solution: 08:33