### Simulation

For this lab, you will develop a program that simulates a patrol car moving around in a 2-dimensional world,looking for suspects. The patrol car’s current location is represented by an (x, y) point in space. Imagine thatthe patrol car can choose a direction command one at a time. The program will have a broad control loop, and for each iteration of the loop, the patrol car must decide what to do (i.e., which command to execute). The goal is for the patrol car to locate all the suspects hidden in its world. The patrol car’s world is 10 × 10 units in size, and the x and y coordinates are in the range [0, 9] (i.e., from 0 to 9, inclusive). Location (0,0) is assumed to be on the top-left corner, to conform computer graphics standards. Add comments to your code, describing each data field, method and class (in the beginning of each file)!!!

### Point2D

Create a new class, Point2D, which has the following:

• two integer data fields, x and y declared according to rules of encapsulation.
• 2 constructors; one of them takes no parameters and sets the fields x and y both to 0, and the other takes two integer parameters and sets x and y values respectively.
• accessor and mutator methods to change the values of its data fields.
• overriden toString() method to display any Point2D object in mathematical format, e.g. (2,7)
• a compareTo(Point2D) method : to return 0, if two Point2D objects have the same x and y values, to return -1, if the caller object’s x and y value is different than the passed Point2D object.
• main method to perform unit test for this class and its methods.

### PatrolCar

Create a new class, PatrolCar, which has the following:

• data fields:
• a unique integer, id, for each PatrolCar object (hint: static modifier)
• a Point2D object variable, location, representing the position of the PatrolCar in the world, an integer data field, arrested which represents the number of suspects this PatrolCar object have arrested.
• a constructor which doesn’t take any arguments, set’s the id to a unique number, initializes the arrested field to 0 and assigns the location to (0,0).
• a method moveWest() which returns false if the PatrolCar is already on the west end of the world (x==0) and decreases x by 1 and returns true otherwise.
• a method moveEast() which returns false if the PatrolCar is already on the east end of the world (x==World.SIZE) and increases x by 1 and returns true otherwise.
• a method moveNorth() which returns false if the PatrolCar is already on the north end of the world (y==0) and decreases y by 1 and returns true otherwise.
• a method moveSouth() which returns false if the PatrolCar is already on the south end of the world (y==World.SIZE) and increases y by 1 and returns true otherwise.
• an accessor method getId(), that returns the id of the PatrolCar
• an accessor method getLocation(), that returns the location of the PatrolCar
• an accessor method getNumSuspectsArrested(), that returns the arrested value of the PatrolCar
• a method addArrested(), which increments the arrested value by 1.
• overriden toString() method to display PatrolCar object’s id, location (call Point2D toString method to display this attribute) and number of suspects arrested.
• a compareTo(PatrolCar) method. Return 0 if two objects have the same id, 1 if the id of the object is bigger than the id of the object passed as a parameter and -1 otherwise.
• main method to perform unit test for this class and its methods.

### World

• data fields:
• an array of Point2D objects, each representing a suspects location. a PatrolCar object.
• a public, static constant integer, SIZE, which represents the world size in each direction, set to 9.
• a constructor which initializes the suspect locations and PatrolCar objects randomly.
• a method update(), which checks if the patrolCar is in the same location as a suspect. If it is it changes the suspects position to (-1,-1) and increases the PatroCar’s arrested value by 1.
• a method move() which moves the PatrolCar in a random direction (east, west, north, south) and for a random number of cells ( upto World.SIZE) and calls update() method at each step.
• application’s main method, which calls the move() method and prints the position and number of arrests made by the PatrolCar object, until all suspects are arrested.