Modifications and advice for Project 4 are listed here in reverse chronological order, with new additions at the top.
It is fine if your program starts building the MaritimeModel object and then quits because it encountered an input file formatting error. Most people will probably implement it this way. The output in this case might look something like:
> java P4 MaritimeModel constructed SimObject Sloop_John_B constructed Ship Sloop_John_B constructed PirateShip Sloop_John_B constructed Error: Line 4 in maritime simulation data file is improperly formatted: "Ship ScullyWagger Pirate 50 101" > _
It is also fine if your program checks every line before building the MaritimeModel object, in which case none of the constructor messages above would have been printed out before the error message.
If you submitted your Project 4 before noon today (Monday), you need to go back and resubmit. But you should only need to add new files. What you already submitted should still be there. We initially planned on running your projects by just using our own SimObject, Island, Ship, CruiseShip, Tanker, PirateShip, and Location classes. But we have now decided that it would be better to collect and test these files that you have created.
To accommodate this short notice, the deadline for Project 4 has been extended by 24 hours. It is now due tomorrow (Tuesday) at 5 PM.
Here is a possible input file (world.txt in this case):
Maritime Simulation World State World_size 100 100 Ship Sloop_John_B Pirate 1 99 Ship ScullyWagger Pirate 50 99 Island Lost 50 10 5 10
Here is one possible command line execution trace. Slightly different versions will be acceptable depending on, for example, when your MaritimeModel gets constructed.
> java P4 MaritimeModel constructed SimObject Sloop_John_B constructed Ship Sloop_John_B constructed PirateShip Sloop_John_B constructed SimObject ScullyWagger constructed Ship ScullyWagger constructed PirateShip ScullyWagger constructed SimObject Lost constructed Island Lost constructed Overwrite existing data file "world.txt"? (Y/N) y > _
The getFileLine() for the Island class should return the following (assuming these data values):
Island Hawaii 87 2 10 3
The 10 is the amount of fuel oil currently available at the island. The 3 is the production rate of oil on that island.
You may find it useful to create an abstract getFileLine() method in SimObject.
The QuittingException class may need a public constructor if it is to be called from stringListToModel() in MaritimeModel.java.
In the Location class, you may add public getX() and getY() methods that return ints. Be careful that you spell them exactly as such since you are not actually submitting this code, but will be using our code in which we've added these methods.
Strike (remove) the <data filename> from the error message. The new error message for any improperly formatted line in the data file is now:
Error: Line <line number> in maritime simulation data
file is improperly formatted: "<The line appears here>"
Answer: P4_1.java should have a main(), as should P4.java.