subject

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

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 08:00
What is the algorithm for building a binary tree program
Answers: 2
question
Computers and Technology, 22.06.2019 14:20
Consider a byte-addressable computer with 16mb of main memory, a cache capable of storing a total of 64kb of data and block size of 32 bytes. (a) how many bits in the memory address? (b) how many blocks are in the cache? (c) specify the format of the memory address, including names and sizes, when the cache is: 1. direct-mapped 2. 4-way set associative 3. fully associative
Answers: 2
question
Computers and Technology, 23.06.2019 13:30
Me ! evelyn is a manager in a retail unit. she wants to prepare a report on the projected profit for the next year. which function can she use? a. pmt b. round c. division d. what-if analysis
Answers: 2
question
Computers and Technology, 24.06.2019 03:30
It is not necessary to develop strategies to separate good information and bad information on the internet. true or false
Answers: 1
You know the right answer?
Implement a class Bug that models a bug climbing up a pole. Each time the up member function is call...
Questions
question
Mathematics, 03.07.2019 10:30
question
Mathematics, 03.07.2019 10:30
question
Mathematics, 03.07.2019 10:30
Questions on the website: 13722361