Question: using c++ 1. Please create a CuteRobot class. Member variable: int position; //in meters. x-axis position Member methods: 1). Constructor(s) //set default position 2). getPosition()

using c++

1. Please create a CuteRobot class.

Member variable:

int position; //in meters. x-axis position

Member methods:

1). Constructor(s) //set default position

2). getPosition() //getter

3). CuteRobot& move(int steps);//Positive number for forward steps, negative number for backward motion. //Ideally, do function chaining here. Otherwise, you may implement: void move(int velocity);

4). void meet(CuteRobot * cr);//The function takes a pointer parameter, calculates the steps value when the cr obj meets this object, assuming this object stands still, and use move() function to bring cr obj to this obj poistion.

2. In main() function

Create an array of five CuteRobot objects. Initialize the position of five robots to 0,1,2,3,4, respectively. Can you use pointer arithmetic to loop through the array and use meet() method to bring every robots to to zero position (where the first robot stands)?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!