Computers and Technology

Implement a class Bug that models a bug climbing up a pole. Each time the up member function is called, the bug climbs 10 cm. Whenever it reaches the top of the pole (at 100 cm), it slides back to the bottom. Also, implement a member function reset() that starts the Bug at the bottom of the pole and a member function get_position that returns the current position. #include using namespace std; class Bug { public: int get position() const; void reset(); void up(); private: int position = 0; }; int Bug::get position() const { } void Bug: : reset() { } void Bug:: up) { } int main() { Bug bugsy; Bug itsy bitsy; bugsy. reset(); itsy bitsy. reset(); bugsy. up(); bugsy. up(); cout << bugsy. get position() << endl; cout << "Expected: 20" << endl; itsy bitsy. up(); itsy bitsy. up(); itsy bitsy. up(); cout << itsy bitsy. get position() << endl; cout << "Expected: 30" << endl; for (int i = 1; i = 8; i++) { bugsy. up(); } cout << bugsy. get_position() << endl; cout << "Expected: 0" << endl; bugsy. up(); cout << bugsy. get_position() << endl; cout << "Expected: 10" << endl; return 0; }

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 12:00, muncyemily
From excel to powerpoint, you can copy and paste a. cell ranges and charts, one at a time. b. cell ranges and charts, simultaneously. c. charts only. d. cell ranges only.
Answers: 3
image
Computers and Technology, 23.06.2019 18:40, cyn95xx
Johnson enterprises uses a computer to handle its sales invoices. lately, business has been so good that it takes an extra 3 hours per night, plus every third saturday, to keep up with the volume of sales invoices. management is considering updating its computer with a faster model that would eliminate all of the overtime processing.
Answers: 2
image
Computers and Technology, 23.06.2019 19:30, bbgirl8638
Of the following pieces of information in a document, for which would you most likely insert a mail merge field?
Answers: 3
image
Computers and Technology, 24.06.2019 02:30, talia43
Assume a class window with accessor method getwidth that accepts no parameters and returns an integer. assume further an array of 3 window elements named winarr, has been declared and initialized. write a sequence of statements that prints out the width of the widest window in the array.
Answers: 2
Do you know the correct answer?
Implement a class Bug that models a bug climbing up a pole. Each time the up member function is call...

Questions in other subjects: