1) Write a C++ program that use the OOD to define and implements the class Robot1DType. The Class Robot1DType simulate a one dimensional robot that can move in two direction over one axis and it has the following variable members Cpos (Current position), Dist (Distance) and Dir (Direction) (of the last robot movements). Moreover, the class has the constructor with default parameters, the Move(Dx), getPos(), getDist(), getDir(), setRobot(cX, cDis, cDir), and Print() methods(functions). The Move(Dx) method is affected on the CPos, Dist and Dir Variables. Ex: Robot1DType Robot(0,0,0) Cpos=0, Dist=0, and Dir-0. Robot.Move(10) Cpos-10, Dist-10, and Dir= +1. Robot.Move(-5) Cpos-5, Dist=5, and Dir= -1.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 15PE
icon
Related questions
Question
I need the answer as soon as possible
for the following.
1) Write a C++ program that use the OOD to define and implements the class RobotIDType. The Class Robot1DType
simulate a one dimensional robot that can move in two direction over one axis and it has the following variable members
Cpos (Current position), Dist (Distance) and Dir (Direction) (of the last robot movements). Moreover, the class has the
constructor with default parameters, the Move (Dx), getPos(), getDist(), getDir(), setRobot(cX, cDis, cDir), and Print()
methods(functions). The Move(Dx) method is affected on the CPos, Dist and Dir Variables. Ex: Robot1DType
Robot(0,0,0)→ Cpos=0, Dist=0, and Dir=0. Robot.Move(10) Cpos-10, Dist=10, and Dir= +1.
Robot.Move(-5)→ Cpos-5, Dist=5, and Dir= -1.
the Inborit
04) Write an operator overloading functions to overload the binary operator+ for the RobotIDType class of Q1 then
overload the insertion operator <<< for the same class. Use the new + operator to add Cpos, Dist and, Dir, of two
Robot1DType objects such that the resulted robot has the sum of Cpos, and Dist of the added robots with keeping the
value of Dir when both are equal otherwise 0. Then use the overloaded insertion operator << to print the resulted robot
in the main
program.
m
Transcribed Image Text:for the following. 1) Write a C++ program that use the OOD to define and implements the class RobotIDType. The Class Robot1DType simulate a one dimensional robot that can move in two direction over one axis and it has the following variable members Cpos (Current position), Dist (Distance) and Dir (Direction) (of the last robot movements). Moreover, the class has the constructor with default parameters, the Move (Dx), getPos(), getDist(), getDir(), setRobot(cX, cDis, cDir), and Print() methods(functions). The Move(Dx) method is affected on the CPos, Dist and Dir Variables. Ex: Robot1DType Robot(0,0,0)→ Cpos=0, Dist=0, and Dir=0. Robot.Move(10) Cpos-10, Dist=10, and Dir= +1. Robot.Move(-5)→ Cpos-5, Dist=5, and Dir= -1. the Inborit 04) Write an operator overloading functions to overload the binary operator+ for the RobotIDType class of Q1 then overload the insertion operator <<< for the same class. Use the new + operator to add Cpos, Dist and, Dir, of two Robot1DType objects such that the resulted robot has the sum of Cpos, and Dist of the added robots with keeping the value of Dir when both are equal otherwise 0. Then use the overloaded insertion operator << to print the resulted robot in the main program. m
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning