Strategy 1
Skills:
- Make an instance variable.
- Define an interface.
- Implement an interface.
- Write a constructor given some information.
Questions:
-
The class
MLMis aStrategythat moves forward, puts down a beeper, turns left, and moves forward again. Write the classMLM. -
Write the class
XBot, which is a class of robot that only moves horizontally.- Starts at street=n, avenue=3 facing East
turnLeftreally turns the robot to face in the opposite direction of the original direction
-
Create a new interface
NamedStrategywhich adds aString stratName()method to the abilities of aStrategy. ThestratName()method should return the strategy’s name. -
Make a class
LaySpeakwhich implementsNamedStrategy. ThedoItmethod both puts down two beepers and prints out the name of the strategy.System.out.println(name of strategy);This kind of strategy should learn its name when it is constructed.