Assignment Instructions Step 1 - We have previously completed the Travel.java program as well as the Waypoint class and Travelable interface (see above links). Modify the above link for Waypoint (to...

Assignment Instructions Step 1 - We have previously completed the Travel.java program as well as the Waypoint class and Travelable interface (see above links). Modify the above link for Waypoint (to make it public and Serializable) and Travelable (to make it public), but don't attach those results. In the chapter on File I/O we discussed how to read and write objects with object input and output streams. Modify the previous Travel.java program and save it as the new Route.java program, but with the following changes: Step 2 - Have your main method read in any previously saved route (if the Route.ser file exists) using object I/O and then enter a main input loop to present a menu of choices to the user, as in the example near the end of the textbook chapter, but don't create a separate enum class to accomplish this (as in the example), just let the user choose to 1) add 2) change or 3) print the list of waypoints, or else just 4) exit the application. Step 3 - If the user chooses 1, call an add method that does pretty much what the old Travel program did previously to create a list of waypoints, except this time they will be stored in an array of type Waypoint class (that we created earlier). Be able to hold at least 10 waypoints. When they finish entering data (the speed of the last waypoint is zero - just like before), present the main menu again. Note that if a previous list already existed (because either a route was read in from a Route.ser file when the program started or because the user previously selected the menu add item while running the program this session) just overwrite the previous list with the new one. Step 4 - If the user chooses 2, call a change method that prompts them for the number of the waypoint to change, then lets them enter the new data (all four items) for the old waypoint. After updating the array, present the main menu again. If the new waypoint has a speed of 0, delete all of the following waypoints in the list as this waypoint will now be the last waypoint in the route. If the waypoint that was previously the last one has its speed changed to a positive (non-zero) value, then after accepting the new data, immediately call the add method to continue building the remainder of the list. Step 5 - If the user chooses 3, call a print method that prints the route as a numbered list of the waypoints in the route (using the toString method of class Waypoint). The numbering used in this list should start at 1 and this is also the number that should be used to identify which waypoint to change using the second menu item (above). The print option should conclude with the distance and time statistics as in the previous Travel program. Step 6 - If the user chooses 4, save each Waypoint in the array to a file called Route.ser (overwriting any previous file) using object I/O and then exit. Additional Instructions: Attach only the source code for Route.java (make sure you spell and case the source code and data files correctly - don't send me any data files, however). I will compile and test your solution. It must compile for any credit (so watch your use of naming and casing to be sure they remain compatible with these specifications). You should not try to use the ArrayList class. You should use ordinary arrays.
Nov 20, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here