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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:20, alcantar28eduin
Print "usernum1 is negative." if usernum1 is less than 0. end with newline. convert usernum2 to 0 if usernum2 is greater than 10. otherwise, print "usernum2 is less than or equal to 10.". end with newline
Answers: 3
image
Computers and Technology, 22.06.2019 17:00, smartoa
Annie is creating a corporate report for a company’s annual meeting. in the report, she wants to add the signature of various department heads. which device can annie use to capture signatures to include in the report? a. printer b. monitor c. e-reader d. digitizing tablet
Answers: 1
image
Computers and Technology, 23.06.2019 11:30, leapfroggiez
Auser is given read permission to a file stored on an ntfs-formatted volume. the file is then copied to a folder on the same ntfs-formatted volume where the user has been given full control permission for that folder. when the user logs on to the computer holding the file and accesses its new location via a drive letter, what is the user's effective permission to the file? a. read b. full control c. no access d. modify e. none of the above
Answers: 1
image
Computers and Technology, 23.06.2019 18:00, MagicDragon4734
Freya realizes she does not have enough in her bank account to use the debit card. she decides to use a credit card instead. which questions should freya answer before using a credit card? check all that apply. can i pay at least the minimum payment each month? can i make payments on time and avoid late fees? will i have to take out a loan? how much in finance charges can i afford to pay? should i talk to a consumer credit counseling service?
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 in other subjects:

Konu
Mathematics, 09.01.2020 07:31