Question: Using the state pattern, you have to implement a robot that can; walk, walk slowly, walk fast, and cook based on an action provided by

Using the state pattern, you have to implement a robot that can; walk, walk slowly, walk fast, and cook based on an action provided by the user. In your design take the following into consideration:

  1. The robot is considered ready after the user switched it on.
  2. The robot can start cooking after walking.
  3. The robot state can go from walk to walk slowly to walk fast based on input from user
  4. The robot goes off after finishing the task (either walking slow, walking fast or cooking) or the user explicitly switch it off.

Q1) (2 points) Draw the state diagram that shows all possible states and transitions?

Q2) (2) Write code of the State Interface?

Q3) (6 points) Write the implementation of the Robot class; most important things are the states declaration, the constructor, a function to return robot state

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!