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 09:00
Which best describes the condition under which the unicode output is the same as plain text?
Answers: 3
question
Computers and Technology, 22.06.2019 11:40
Design a pos circuit that displays the letters a through j on a seven-segment indicator. the circuit has four inputs w, x, y, and z which represent the last 4 bits of the uppercase ascii code for the letter to be displayed. thus, if wxyz = 0001 then "a" will be displayed. (any answer with 22 or fewer gates and inverters, not counting any for the inputs, is acceptable)
Answers: 2
question
Computers and Technology, 22.06.2019 16:10
When copying and pasting text, the first step is move your cursor type the text select the copy command select the paste command
Answers: 2
question
Computers and Technology, 23.06.2019 02:00
Which of the following is not a source of sustainable raw materials? a) coal mine b) flick of sheep c) cotton plantation d) line forest.
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, 11.03.2020 02:38
question
English, 11.03.2020 02:38
question
Mathematics, 11.03.2020 02:38
Questions on the website: 13722359