Question: C++ 2 130 TS0 points) Write a class Bug that models a bug moving along a horizontal line. The bug moves either s the right

C++  C++ 2 130 TS0 points) Write a class Bug that models

2 130 TS0 points) Write a class Bug that models a bug moving along a horizontal line. The bug moves either s the right or left. Initially, the bug moves to the right, but it can turn to change its direction. In each rection. move, its position changes by one unit in the current di The header file for this class is given blow: rifndef BUG H define BUG H alass Bug publia nitialize porition to initial position, and set Bug (int 1ni tial_position = 0); void turn();ehange the:signorthe data member direction void move ) int got_position) private: int position; int direction; 17 for g #endif a) Implement the constructor that initialize data members position and direction. [5 points] b) Implement member function move .[10 points c)Implement member function turn O. (10 points d) Write a main function that creates a Bug object, make it move and turn a few times, and print its positions. (5 points

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!