Denver Smith -- denverpsmith@gmail.com
12/03/2015
This is a simple class library that allows robots to perform jobs or tasks. There are two types of robots: MasterRobots and HelperRobots. MasterRobots can perform one task at a time, unless they have the help of a HelperRobot. The MasterRobot keeps a queue of tasks to be performed if it's already busy. Also, MasterRobots can ask HelperRobots for help with tasks. A HelperRobot can also only perform one task at a time, and will not accept a new task until it's finished.
- Python2.7
- Clone or download the git repository package: https://github.com/denvaar/RobotClassLibrary
- Add the
src
directory to your PYTHONPATH environment variable. - Run the example script:
python src/driver.py
from masterRobot import MasterRobot
from helperRobot import HelperRobot
from robotMediator import RobotMediator
# Create a mediator
mediator = RobotMediator()
# Create a master robot and register it with the mediator
master = MasterRobot(mediator)
# Do the same with the helper
helper = HelperRobot(mediator)
# Assign tasks with doWork() method.
master.doWork()
# Finish tasks with finishWork() method.
master.finishWork()
See driver.py for more examples.
- Mediator design pattern is used to decouple MasterRobot from HelperRobot. This pattern offers a simple and effective solution to allow these robots to communicate with each other without having to know about each other.
- Both types of robots implement the Robot interface. Programming to an interface rather than an implementation is an effective way to decouple the underlying design from the specific implementation. Users may wish to extend the class library to include more types of robots, in which case they may implement the Robot interface.
- Inheritance and aggregation are used among classes.
src/
Source code directory.
tests/
Unit tests.
doc/
Documentation directory.