Class Dog
java.lang.Object
Dog
Represents a Dog and keeps track of the number of times
the dog has performed bodily functions.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Dog
Creates a dog with the specified name Half of the times a new Dog is created, the dog walks fast, the other half of the time, the dog walks slowly. The number of poops per hour should be randomly generated but never zero.- Parameters:
name
- name of the dog
-
Dog
Creates a dog with the specified information- Parameters:
name
- name of the dogwalksFast
- true if this is a fast walking dogproductionRate
- the average number of times the dog poops when walking for one hour, if the value passed is less than one, it should be set to 1.
-
-
Method Details
-
toString
A description of the dog as a string. The description should match this format:Spot is a fast walker who peed 12 times and pooped 1 time.
-
getName
The name of the dog- Returns:
- The name of the dog
-
walk
public boolean walk(int minutes, boolean fast) Walk the dog either fast or slowly. If the dog walks slowly but this is a fast walk, the dog will refuse to go on the walk 25 percent of the time. Otherwise, the method simulates the dog going on a walk. The number of times the dog pees is a random value between zero and the number of minutes the walk is. The method also displays a summary of the walk to the console. For example:Spot went on a fast 41 minute walk and even pooped.
orSpot went on a fast 41 minute walk.
orSpot is slow walker and refused to go on this fast walk.
The method determines whether the dog poops on the walk in a randomized way based on the dog's average poops per hour information.- Parameters:
lengthInMinutes
- Number of minutes the dog is walkedfast
- true if and only if this is a fast walk- Returns:
- true if and only if the dog pooped on the walk
-
getTotalTimesPeed
public int getTotalTimesPeed()The total number of times the dog has peed.- Returns:
- The total number of times the dog has peed.
-
getTotalTimesPooped
public int getTotalTimesPooped()The total number of times the dog has pooped.- Returns:
- The total number of times the dog has pooped.
-