Specification:
This project is a robot simulation. The goal is to create a simulation determine how long randomly moving robots can "survive" in the world.
As sample run might look like this:
Enter the number of Robots:
4
Running simulation ...
Move 1:
Robot 1 (0, 0)
Robot 2 (99, 0)
Robot 3 (0, 99)
Robot 4 (99, 99)
Move 2:
Robot 1 (-1, 0)
Robot 2 (99, -1)
Robot 3 (-1, 99)
Robot 4 (100, 99)
The simulation lasted 2 moves.
As an alternative you can graphically display the robots and the results.
Specification:
The simulation world is 100 x 100. Each Robot starts in a random location in the world. When a Robot leaves the world, it is dead and no longer moves.
For every Move of the simulation each Robot will move randomly either to the left, right, up, or down one space.
When all the Robots are dead the simulation is over.
Test Program
Create a Robot class with the following methods:
void initialize( int xPos, int yPos)
void moveLeft()
void moveRight()
void moveUp()
void moveDown()
int getXPosition()
int getYPosition()
void setDead()
boolean isDead()
Write a test program to test each method of the Robot Class.
Here is an example of a test case:
Robot r = new Robot();
r.initialize(10, 10);
r.MoveRight();
if ( r.getXPosition() == 11 ) {
System.out.println("Pass");
}
else {
System.out.println("Fail");
}
Requirements:
All source code must be written in Java
No Magic Numbers
The test program must test the functionality of the Robot class
The simulation program must utilize the Robot class
The source code must be fully commented