Exercise: Game of Robots
Let's play a game of robots before moving on to the next chapter.
We'll cover the following
Problem Statement
The robot game that we developed early in this chapter is given below. Let’s edit our game with the following changes.
Let the initialize
method accept another option—the number of a robot, so this number is another parameter that defines the state of a particular robot instance. Modify the up
and down
methods so that these methods are no operations and do nothing if the number is odd. If the number is even, right
and left
methods should be no operations. Try to guess how the animation will look like with these changes.
Get hands-on with 1400+ tech skills courses.