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...


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 compileMotorcycle.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





It’s 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_



Hint: Use rand() from thelibrary 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 doesn’t work, it’s 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


Implement the followingpublicmethods:




/** updates direction_ @param degrees: -360



Hint: Use the following visualization to influence your implementation ofturn().



Relative Location of Bike


Implement the followingprivatemethod:



/** 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. It’s 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 programsINCREMENTALLY!!!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 ownmain()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 Don’t forget to go back and implement the stub!!! If you put the word STUB in a comment, some editors will make it more visible.

Feb 08, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here