Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

class Robot { public: int x,y; char heading; Robot(int start_x,int start_y, char

ID: 3602768 • Letter: C

Question

class Robot {
public:
int x,y;
char heading;
Robot(int start_x,int start_y, char start_heading) {
x = start_x;
y = start_y;
heading = start_heading;
}
void setX(int i) {
x = i;
}
void setY(int i) {
y = i;
}
int getX() {
return x;
}
int getY() {
return y;
}
void setHeading(char c) {
heading = c;
}
char getHeading() {
return heading;
}
};

use c++

Copy your class "Robot" from the previous question. Add the public functions turnLeft, turnRight, and moveForward. The functions should update the robot's x, y, and heading attributes and should not return anything. turnLeft and turnRight should update the robot's heading. If the robot's heading is turnLeft should result in the new heading being 'W moveForward should update the robot's x or y position by 1. If the robot's heading is 'N', moveForward should result in the y position increasing by one. If the robot's heading is 'S', moveForward should result in the y position decreasing by one -3

Explanation / Answer

#ifndef POINTTYPE_H_INCLUDED
#define POINTTYPE_H_INCLUDED
#include <iostream>

class pointType{
public:
pointType (int=0, int=0);
int getX() const;
int getY() const;
void setX(int);
void setY(int);
void setValues(int, int);
friend pointType operator + (pointType, pointType);
friend pointType operator - (pointType, pointType);
friend std::ostream& operator << (std::ostream&, pointType);
private:
int x;
int y;
};

#endif // POINTTYPE_H_INCLUDED