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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started