Question: Consider the below sketch (i.e. not all members, methods defined) of class structure for the motion handler. Indicate which design pattern it is using, if
Consider the below sketch (i.e. not all members, methods defined) of class structure for the motion handler. Indicate which design pattern it is using, if any:
class MotionHandler {
public: virtual void UpdateVelocity(); WheelVelocity get_wheel_velocity() {return wheel_velocity_;} Void set_wheel_velocity(WheelVelocity wv) { wheel_velocity_ = wv; } private: WheelVelocity wheel_velocity_; } class MotionHandlerUserControlled : public MotionHandler { public: void UpdateVelocity(); } class MotionHandlerAutonomous : public MotionHandler { public: void UpdateVelocity(); } class Robot { public: Robot() : motion_handler_(new MotionHandlerUserInput); void Update() { motion_handler_->UpdateVelocity(); } private: MotionHandler * motion_handler_; a. Singleton
b. Template
c. Command
d. Strategy
e. Observer
f. None of the Above
1.2 Consider a simulation in which the robot is user controlled until it has lost all of its lives. Instead of dying, it becomes autonomous using the behavior as defined in MotinoHandlerAutonomous above. What one line of code in ChangeToAutonomous() would change the robot from user controlled to autonomous (ignoring memory management)?
void Robot::ChangeToAutonomous() { >>>> WHAT GOES HERE ?? }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
