|
Wyo Java Ch7Proj2 |
|
Extend Ch7Proj1 with the additional specifications. Add another constructor to the Fish class that allows a client to instantiante a fish with a specified location and direction. Instantiate one fish in (0, 0) with East as an initial direction. Instantiate a second fish in the position (1, 0) with a direction of west. Add code to the project to allow each fish to make 20 moves sequentially, one after the other but make sure that the two fish never share the same location. If a fish is blocked by another fish when it's his turn to move, the fish should stay in place. But, it should still use a pseudorandom number to turn right, turn left, or keep its original direction. After each fish moves, display the position of both fish so that you can determine that they do not inhabit the same location at any moment of time. if necessary, your algorithm may move a fish, check to see if two fish inhabit the same location, and then move the fish back to its original location. Just make sure that the two fish do not inhabit the same location when their positions are displayed in the output window of the test class. Display your name and the project name on the first line of output. Here is a sample output screen.
Your program must follow the class Coding Standards. Save all of the files associated with this assignment to a folder named Ch7Proj2 in the appropriate network folder. Preconditions:
You must hand in the following on separate pages stapled in this specified order:
|