Using C++ thanks! Add the public functions turnLeft, turnRight, and moveForward.
ID: 3730850 • Letter: U
Question
Using C++ thanks!
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 'N', 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 Question 3 Not answered Mark 0.00 out of 1.00 P Flag question Answer (penalty regime 0 %)Explanation / Answer
There are three public methods with no return type are :
turnLeft()
turnRight()
moveForward()
Now coming to coding part:
char head = ' ';
int x,y;
if (head == 'N')
{
head = 'W';
x=x+1;
y=y+1;
}
if (head == 'N')
{
y=y+1;
}
if (head== 's')
{
y-- ;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.