Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

language: c++ subject: creating classes, and header file Submit the file with the .cpp extension containing your CH source code. Submit a cpp files or

language: c++
subject: creating classes, and header file image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Submit the file with the .cpp extension containing your CH source code. Submit a cpp files or pdfs as the problem dictates. No handwritten submissions. Teams of up to 3 are allowed. Put the names of all team members on a single submission. You may use the Robot.h and Robot.cpp files we have developing in class for this homework. Specifically, make sure you are starting with the following Robot class defined within your respective header and source files. In Robot.h: #ifndef ROBOTH #define ROBOT H class Robot public: Robot(); //member functions private: //data members #endit In Robot.cpp: #include "Robot.h" Robot: Robot() { In main In main #include #include "Robot.h" using namespace std; int main() { return 0; 1. Implement the following statements: a. Add two data members of type int called i XPosition and iyPosition. b. Initialize the position each of the data members (x,y) to 0 in the constructor c. Create setters and getters for these variables. d. Add a member function called Movex which shifts the bot's position from x to x+k, where is an int parameter to the function. e. Add a member function called MoveY which shifts the robot's position from y to y+k, where k is an int parameter to the function. f. Add a member function called MoveDiagonal which moves the robot's position to **k and y*k, where k is an int parameter to the function. g. Add a member function called Move Random, which moves the robot to a random position 2. Implement the following statements (building from the robot you created above): . Add code that stores the distance traveled after a call to one of the Move functions b. Create a data member of type const int called iBattery Amps. c. Create a getter for this data member. The getter function for this member should be a const qualified member function, ensuring that the getter cannot manipulate the object's data, and enabling const Robot objects to use this member function. d. Make the constructor take an integer parameter and set the iBattery Amps variable to be this input. Do not create a second constructor, modify the original. e. Add a data member of type float called fBatteryDraw. Initialize this data member to 0 in the constructor. After each call to a move function, update the fBatteryDraw variable according to fBatteryDraw + distance * 0.128. f. Add a member function that provides a pointer to the BatteryDraw variable. g. Add a member function called calculateDischargeTime which calculates the amount of time until the battery will be discharged as Batteryamps = time e hours. 3. Implement the following statements (building from the robot you create above): a. Make the battery draw also depend on the robot's weight. Add a data member for weight with related setter/getter code and initialization in the constructor. You can choose a sensible default initial weight to initialize this data member. b. Create five robots in main each with a unique value for battery amps. c. Make 20 arbitrary (but unique for each robot) moves. d. Print the draw for each robot to the console after the moves. Print the discharge time for each robot. 4. a. Implement the following statements (begin from the robot you create in Q3): Use the new keyword to create three more robots each with a unique value for battery amps. Make enough arbitrary moves to demonstrate that once the battery charge is too low the robot will not move. Print the draw for each robot to the console after the moves. Print the discharge time for each robot. C

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions