Ask C/C++ Expert


Home >> C/C++

Instructions
We have previously completed the Travel.java program as well as the Waypoint class and Travelable interface. The source code to all of these is published in the Resources area here. Modify my versions of Waypoint (to make it public and Serializable) and Travelable (to make it public), but don't attach those results (I will just use my own copies).

In the chapter on File I/O (and my lectures) we discussed how to read and prepare objects through object input and output streams. 

Modify the previous Travel.java program and save it as the new RouteApp.java program, but with the following changes:

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 ex near the end of the textbook chapter, but don't create a separate enum class to accomplish this (as in the ex), just let the user choose to 1) add 2) change or 3) print the list of waypoints, or else just 4) exit the application.
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 make sure to store them as an array of waypoints (using our earlier work). Be able to hold at least 10 waypoints in the array (I won't test for more than this). When the user finishes entering data, the speed of the last waypoint should be zero (just like before - that's how you know to end the add mode) and your main loop should display the menu again. Note that if a previous list already existed (because either a route was read in from the route.ser file when the program started or because the user previously selected the menu add item while running the program during this session, just overprepare the previous list with the new one.
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) to replace the values in the old waypoint. After updating the route, 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.
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) to the console. 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. Finally, the main loop should present the menu again.
If the user chooses 4, save each Waypoint in the array to a file called route.ser (overwriting any previous file) using Java Object I/O and then exit. Note, do not prepare the entire array as one object to the file. Each Waypoint element should be written seperately to the file.
Attach only the source code for RouteApp.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). 

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M995877

Have any Question?


Related Questions in C/C++

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As