Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C + + PLEASE, READ CAREFULLY ( USE ATTACHED TEMPLATES ) For bug.h use this template PLEASE - #ifndef BUG _ H #define BUG _
C PLEASE, READ CAREFULLY USE ATTACHED TEMPLATES For bug.h use this template PLEASE #ifndef BUGH #define BUGH class Bug public: private: ; #endif for bug.cpp use this template PLEASE #include "bug.h To check code use this template Do not edit this file. #include "bug.h #include #include using namespace std; class Tester public: Checks answer and prints success or failed bool testdouble got, double expected; private: sizet testnum ; double thresh ; ; bool Tester::testdouble got, double expected cout Test case testnum endl; bool success true; if absgot expected thresh cout "Not passed yet. Keep trying!" endl; cout Got: got endl; cout Expected: expected endl; success false; cout endl; if success cout "Passed." endl endl; testnum; return success; int main Tester tester; bool allpassed true; Test case Bug bugsy Bug; bugsymove; bugsymove; bugsyturn; bugsymove; bugsymove; bugsymove; bool testcasepassed tester.testbugsygetposition; allpassed testcasepassed allpassed; Test case Bug bugsy Bug; bugsymove; bugsymove; bugsymove; bugsymove; bugsymove; testcasepassed tester.testbugsygetposition; allpassed testcasepassed allpassed; Test case Bug bugsy Bug; bugsyturn; bugsymove; bugsymove; bugsymove; bugsymove; bugsyturn; bugsymove; testcasepassed tester.testbugsygetposition; allpassed testcasepassed allpassed; Test case Bug bugsy Bug; tester.testbugsygetposition; allpassed testcasepassed allpassed; Test case Bug bugsy Bug; bugsyturn; bugsyturn; bugsyturn; testcasepassed tester.testbugsygetposition; allpassed testcasepassed allpassed; if allpassed cout "Hooray, you passed all tests!" endl; return ; Problem : Bug Please turn in bug.h and bug.cpp that contains your implementation of the Bug class. I provided starter code bug.h and bug.cpp I also provided bugmain.cpp which contains the main function and testers. You should not modify bugmain.cpp In bug.h you need to provide the class definition In bug. cpp you need to provide implementations of the member functions. For bugmain.cpp you will not edit this, but you will run this and it will test your implementation. Please pass all tests before submitting your bug. h and bug. cpp Write a class Bug that models a bug moving along a horizontal line. The bug moves either to the right or left. Initially, the bug moves to the right, but it can turn to flip its direction if the current direction is right, turn to left; if the current direction is left, turn to right In each move, its position changes by one unit in the current direction. Provide a constructor Bugint initialposition and member functions void turn void move int getposition const Sample usage: Bug bugsy; bugsy.move; Now the position is bugsy.turn; bugsy.move; Now the position is Note: There will be no user input. Just run the bugmain. cpp and check your answers.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started