Reference no: EM132307337
Project - Linked List Train Application
You're going to create a linked-list and an application to simulate a Train Scheduler.
You're going to have a menu with the following selections:
1) Add a car to the train.
2) Add a car to the back of the train.
3) Add a car to the train at a specific position.
4) Remove the first car from the train.
5) Remove the last car from the train.
6) Remove a car from the train at a specific position.
7) View the train and all of its cars.
8) View all of the removed cars.
9) Remove all of the train's cars.
10) Exit
You're going to create a Node class with the following properties:
String cargo
Node next for next node (or what it's pointing to)
If the user asks to add a new car you're going to prompt them for the cargo.
Regardless of where they'd like to add the car. Keep prompting them until they give you a valid string.
When a user asks to add a car to the front then add it to the front.
If they ask to add it to the back then add it to the back. You'll have a method for each of these.
If they ask to add it to a specific position, you're going to list the available choices for them. So, if there are three cars and they select the menu option 2 for adding it to a specific location you're going to ask them if they'd like to add from 0 to 4. One would be in front of the head car. 2 would be in between the first and second car. 3 would be in between the second and third car. And 4 would be at the back. If they choose anything else then keep prompting them until they enter a correct position.
You will then add accordingly. So, a 1 would again call the method to add to the head. A 4 (or whatever the last position is) would call the method to add it to the back of the train. Otherwise you'll add it at the position they are asking for.
Same with removal. Remove from front, Remove from back, Remove from position. When you remove the car you're going to add it to a second linkedlist called removedCars. Don't worry about positioning, just add them to the back.
The view the train will display all of the cars with their cargo and position in a neatly formatted way.
The view removed cars will display all of the removed cars and their cargo, not position.
The empty train selection will remove all of the cars placing them in the removed cars linked-list in order from front to back as they were in the train.
The last selection will exit the program.
Note - This have to be done in Dr.java as well as netbeans.
Attachment:- Assignment File.rar