Java代写 | EECS 2030 Assignment 1 Fall 2020

本次Java代写是完成城市汽车规划相关的程序

EECS 2030 Assignment 1
Fall 2020

Task 1:
The first task is for you to construct the map of the city by implementing the constructor of the class.
As you will see from the code, the constructor gets the number of rows and columns to make the map
of the city.
public Map(int , int)
Task 2:
The second job for you is to write a recursive method that returns a path from a source to a
destination. Implement the following method, when we know the car is traveling to south west. The
starting and stopping intersection is given as the input parameter. You can see the description of the
input parameters in the JavaDoc of this method. Please note that the following method is a ‘private’
method that cannot be tested by the tester directly. The tester can only test this method indirectly
by the method that is implemented for task 4. My suggestion is to partially implement task 4, so the
tester can test this method.
private String goSouthWest (int , int , int , int , String )
sample input: 5,5, 4, 1, ” ”
one sample Expected output: (4,5) (4,4) (4,3) (4,2) (4,1)
Task 3:
If you were able to complete the second task, this task is a piece of cake for you. Use the same
approach that you used for task 2, to implement the three following methods.
private String goSouthEast (int, int, int, int, String)
private String goNorthEast (int, int, int, int, String)
private String goNorthWest (int, int, int, int, String)
Again, the above methods are private, which cannot be tested by the tester directly. It’s better to
partially implement task 4, in order to test these methods.
Task 4:
As you probably noticed, all the 4 methods above are private. It means a client (i.e. a self driving car)
cannot use these methods. So as your fourth task, you need to implement getPath method, which
has two responsibilities. The first responsibility is to check if all the inputs are valid. If it was not valid,
then this method should issue an IllegalArgumentException. It is your job to figure out what a valid
input means.
The second job of this function is to decide in which direction the car should travel. It should call one
of the four methods that you have just implemented, depending on the direction that the car is
moving. This method is not a recursive method.
public String getPath (int, int, int, int, String path)
Task 5:
Suppose that a police car is chasing the self-deriving car. The car wants to get out of the city map (i.e.
the grid). We know that our police are capable enough to catch the car ultimately, so we let the selfdriving car to be adventurous for a while before the police car stops it. Whenever the car passes an
intersection, a police car is deployed at that intersection. This means that the car cannot pass an
intersection for the second time, otherwise it will be caught by the police. So, as long as the car does
not pass an intersection more than once, it can travel to any direction to finally get out of the city.
Please see figure below that shows some example of the path that our car has passed in the different
experiments. The starting point for first two examples is intersection (3, 3) and for the third example
is (3, 2). In the two first example, the car was able to exit the city, however in the third example, it
was caught by the police.
As the car starts to travel, it chooses the next intersection randomly. That is why the car may get
caught by the police. If the car is caught by the police, the game starts over. The car is positioned at
its original place, where it starts to randomly choose a path out of the city.
Your job for this problem is to implement the following method that takes in the intersection number
and produces a path out of the city. If the car was caught by the police, the method should start over
and keep doing this until it finds a path out.