Task 1:
Implement the following default and parameterized constructors:
Motorcycle(); // brand_ <- a random bike type
// curr_acceleration_ <- bike_details::NONE
Motorcycle(int kind_of_bike); // initialize all members besides brand_ to the values that
// they take on in the default contructor
// brand_ <- kind_of_bike
Hint: Use rand() from the <stdlib.h>
library to produce random values.
Task 2:
Implement following getter functions:
/**
return the string that corresponds to the curr_direction_ that the caller faces
relative to a cartesian plane; assume that the caller is at position (0,0),
the degree measure of (1, 0) is 0 degrees, and the degree measure of (-1, 0) is 180 degrees
"North" == 90
0 < "Northeast" < 90
"East" == 0
"Southeast" > 270
"South" == 270
180 < "Southwest" < 270
"West" == 180
90 < "Northwest" < 180
*/
std::string getDirection();
string getBikeType(); // string version of brand_
float getSpeed(); // curr_speed_
float getDistanceTraveled(); // distance_traveled_
int getIntensity(); // curr_acceleration_
Implement the following public
methods:
/**
updates direction_
@param degrees: -360 <= degrees <= 360, and if the user enters a number outside of these
bounds adjust @param degrees to be within this range
*/
void turn(float degrees);
Hint: Use the following visualization to influence your implementation of turn()
.
Implement the following private
method:
/**
alters curr_speed_ depending on curr_speed_, curr_acceleration_, and brand_
USE THE FOLLOWING FORMULA: [ (acceleration) / 8 ] + [ (brand) * 17.64 ]
*/
void updateSpeed();
Task 3:
Implement the following public method:
/**
if the current acceleration is not HIGH increase it by one level and call updateSpeed()
*/
void accelerate();
/**
if the current acceleration is not NONE decrease it by one level and call updateSpeed()
*/
void brake();
/**
given curr_speed_, curr_acceleration_, brand_, and @param float duration,
calculate the distance traveled during the specified time;
increment distance_traveled_ by this amount
@param float duration: time traveled
@return: updated distance_traveled_
*/
float ride(float duration);
Get Free Quote!
347 Experts Online