Question: Purpose of the Hare class Fields The arrogance field will store a value between 0 and 1 ( a percentage ) that indicates the degree
Purpose of the Hare class Fields
The arrogance field will store a value between and a percentage that indicates the degree of arrogance of this Hare. For example, a Hare that is arrogant will nap half of the time, and run half of the time, while a Hare that is arrogant an arrogance of will nap of the time and run only of the time.
Note that most of the fields of the Hare class are those that are inherited from the Racer super class ie name, distanceCoveredInMeters, minSpeedInMetersPerSecond, maxSpeedInMetersPerSecond
The parameterized constructor initializes the new Hare object.
This constructor should call the parameterized constructor of the super class, and pass the name parameter value to the super class constructor, along with the minimum speed for a Hare meters per second and the maximum speed for a Hare meters per second as arguments. This constructor should also initialize the arrogance field with the value of the arrogance parameter.
The run method simulates this racer running for one time interval.
This method will first compute a random percentage a value between and If that value is less than the arrogance of this Hare then this racer will take a nap instead of running for this time interval. the total distanceCoveredInMeters will not be updated, and a message formatted like the following will be printed.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
