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 11:40
Pthreads programming: create and terminate a thread write a c++ program that creates a thread. the main will display a message “hello world from the main”. the main will create a thread that will display a message “hello world from the thread” and then terminates with a call to pthread_exit()
Answers: 3
question
Computers and Technology, 23.06.2019 02:30
Rafael needs to add a title row to a table that he has inserted in word. what should he do? use the alignment options. use the merge and center option for all the cells in the top row. use the merge and center option on the first two cells in the top row. none of the above
Answers: 3
question
Computers and Technology, 23.06.2019 07:30
What is the penalty for violating section 1201 of title 17 chapter 21 of the us code
Answers: 1
question
Computers and Technology, 24.06.2019 00:30
Use the keyword strategy to remember the meaning of the following word. the meaning for the word has been provided. write your keyword and describe the picture you would create in your mind. obfuscate: to make something so confusing that it is difficult to understand.
Answers: 2
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, 19.02.2022 16:10
question
Mathematics, 19.02.2022 16:10
question
Mathematics, 19.02.2022 16:10
question
Mathematics, 19.02.2022 16:10
question
History, 19.02.2022 16:20
question
Mathematics, 19.02.2022 16:20
question
Mathematics, 19.02.2022 16:20
Questions on the website: 13722363