Designing a Robot Simulator
Form groups of two or three You should write down the group's solution as you go so that it can be compared with others' solutions.
This project is intended to get you to try to design a program without worrying about exactly how it will be implemented. In other words, you should explore a design in enough detail to convincingly answer the questions below without writing any actual code.
Specification
You should design a program to simulate the operation of a Lunar Mining Factory at which ore and other precious metals are packaged into boxes for export to other worlds. The boxes are transported by rocket, robots are used to move the boxes from the factory to the rocket. When the robots are done unloading their boxes, they carry supplies from the rocket back to the factory. Rockets land on special landing pads near the factory they serve.
A robot unloads a box at a rocket, picks up a box of supplies if available, then heads back to its factory. At the factory a robot unloads its cargo, loads another box, and heads to a rocket. Robots may have to wait at the factory until a box they can carry becomes available. Robots are loaded with a box on a first come, first served basis. As soon as a box is ready, it is put on the first robot that can handle the box. It takes time to load and unload boxes depending on the box's characteristics. Robots unload boxes in the order at which they arrive at a rocket. Boxes are filled by each factory at a fairly consistent schedule.
There are various kinds of boxes (e.g., big, small, purple, green, perishable, flammable, light, heavy, etc.). Some robots can carry all boxes, other robots can only carry certain kinds of boxes. Robots also move at different speeds depending on what kind of motor the robot has. Your simulation should be able to handle any number of lunar factories, any number of rockets serving each factory, and any number of robots moving between the two.
Your simulation should have at least two visible components, i.e., displaying all robots as moving entities between rockets and factories and displaying a history of factory's productivity.
Use Cases
Test your design against the following scenarios by role playing or drawing an interaction diagram for each:
- A factory is ready to send a box to a rocket, a robot is selected and given the box of goods
- A factory is ready to send a box to a rocket, but no robot is available that can handle it. After a while, one arrives
- A robot with a box arrives at its destination and must wait to unload its box behind two other robots
- A rocket arrives and begins to unload cargo
Change cases
Once you have tried your design on each of the use cases above and feel confident it works properly, incorporate the following additions and document the changes necessary to your design. In particular, how many classes/methods need to changed/added to add the following:
- Describe how you might allow a user to set up a simulation like this (i.e., from a file, command-line arguments, or using some kind of graphical user interface).
- Boxes must have at least the following properties: color, any valid Java color may be allowed; size, one of the following values: small, medium, large, huge, skinny, or tall; weight, any valid real number in the range 1.0 to 10000.0 inclusive; contents, one of the following values: perishable, radioactive, flammable, fragile, hazmat, or liquid. Additionally, any of these values may be used to give the box a "priority" that requires a factory to produce and load that box as soon as possible; or get it on the fastest possible robot, etc. For example, a rocket might need only red boxes to fill its quota so it can leave; or a perishable box may need to be rushed to the nearest rocket for transport.
- Robots move between factories and rockets carrying boxes; however, occasionally, they may break down (based on the number of trips they have made). When a robot breaks down, it must be repaired by the factory that created it. If another robot comes upon one that is broken down and it is not carrying anything, it should first take the disabled robot's box to the place it is intended to go (if the working robot is able to carry the disabled robot's type of box). If the disabled robot is no longer carrying a box, then it should be carried back to the factory where it was created. A robot should only carry another to a factory if it was already intending to go there. In other words, robots only stop to help empty handed disabled robots if it is convenient to do so.
- Expand your simulation to include other similar worlds. Specifically, rockets carry cargo from one world to another based on a number of factors. Generalize your design to find the common abstractions between factories and worlds, rockets and robots, etc.