Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project 0 The objective of this project is to refresh your knowledge of class objects and enums from CSCI 135. This will require you to

Project 0

The objective of this project is to refresh your knowledge of class objects and enums from CSCI 135. This will require you to implement a class, Motorcycle, in addition to its private and public member functions, which will be specified in a further section of this document. In order to successfully complete this project, we strongly recommend that you look back to your CSCI 135 coursework as a reference. You have given the Motorcycle.hpp file; all that you must do is create and successfully write and compile Motorcycle.cpp.

Implementation

Work incrementally! Work through the tasks sequentially (implement and test). Only move on to a task when you are positive that the previous one has been completed correctly. Remember that the names of function prototypes and member variables must exactly match those declared in the respective header file when implementing a class.

Task 1: Buying your very own Motorcycle

Its 10pm and you are on your way to Walmart for your weekly pillaging of necessities: hand sanitizer, toilet paper, Nutella, and the other usuals. On your way there you meet a biker gang, FBK, at a red light. For a brief moment it looks like they are laughing at you, that is until the light turns green and you accelerate to max speed in record time. Suprised, the bikers rides alongside you, offering you a place in their gang. There is one problem, you do not have a motorcycle. Their leader, C.S. Brian, gives you their contact information and you head to your local bike shop the next day. The owner gives you two options:

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 library to produce random values.

Task 2: Motorcycle Operations

Now that you have received your Motorcycle, you want to test its capabilities. Check out how it works! Remember, there is no warranty on your Motorcycle; so if a component doesnt work, its up to you to fix it! You do not want to embarrass yourself on your first day.

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: Time to hit the road

Your Motorcycle works as intended and the FBK are awaiting your arrival. Its time to hit the pavement!

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); 

Testing

How to compile:

g++  -std=c++17 

You must always implement and test you programs INCREMENTALLY!!! What does this mean? Implement and test one method at a time.

  • Implement one function/method and test it thoroughly (multiple test cases + edge cases if applicable).
  • Implement the next function/method and test in the same fashion. How do you do this? Write your own main() function to test your class. In this course you will never submit your test program, but you must always write one to test your classes. Choose the order in which you implement your methods so that you can test incrementally: i.e. implement mutator functions before accessor functions. Sometimes functions depend on one another. If you need to use a function you have not yet implemented, you can use stubs: a dummy implementation that always returns a single value for testing Dont forget to go back and implement the stub!!! If you put the word STUB in a comment, some editors will make it more visible.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions

Question

OUTCOME 6 Explain and give examples of diversity management.

Answered: 1 week ago

Question

Compute the derivative f(x)=(x-a)(x-b)

Answered: 1 week ago