Instructions Use the following information to create a program for a train reservation system. Your program...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Instructions Use the following information to create a program for a train reservation system. Your program should contain three separate classes: a Passenger class, a Reservation class, and a Demo class. In this program, the Reservation class will function as a doubly linked list that contains Passenger objects. The Demo class will be used to make modifications to the Reservation list. Passenger Class This class should contain the following fields: name: String phone: String seat: int o This is the seat number assigned cost: int o This is the cost the passenger paid (each seat may have a different price) next: Passenger o This is a reference to the passenger that follows this passenger in the list • previous: Passenger o This is a reference to the passenger that precedes this passenger in the list The Passenger class should contain the appropriate getters and setters for these attributes, a no-arg constructor, and a constructor that accepts the following arguments: name, phone, seat and cost. Reservation Class This class will act as our doubly linked list. This class should contain the following attributes: • head: Passenger o A dummy node (a blank passenger object that will represent the first passenger in the • head: Passenger o Page: 1 A dummy node (a blank passenger object that will represent the first passenger in the reservation list) tail: Passenger o A dummy node (a blank passenger object that will represent the last passenger in the reservation list) size: int o The number of reservations in the reservation list CSC 249 Data Structures and Algorithms Project - 1 (Reservation System) Note: Make sure to review the section in your book on Dummy Nodes - they should help simplify the logic required for methods that operate on the Reservation class. The Reservation class should contain a no-arg constructor which initializes the size, head and tail attributes. This no-arg constructor should also properly connect the head and tail nodes of the doubly linked list. The Reservation class should also contain the following methods: • A method that accepts a Passenger object and adds it to the end of the reservation list. A method that accepts two Passenger objects (a new Passenger to be added, and a Passenger that is currently pointed in the reservation list). This method will insert the new Passenger into the reservation list at the position directly after the Passenger that is currently pointed.. • A method that accepts a Passenger object, returns nothing, and removes the Passenger from the reservation list. • A toString method that prints out the contents of the reservation list. This toString method should also calculate and display the number of passengers in the reservation list, as well as the total cost • A toString method that prints out the contents of the reservation list. This toString method should also calculate and display the number of passengers in the reservation list, as well as the total cost paid by the passengers in the list. Demo Class This class will serve to accept user input and manipulate the Reservation doubly linked list. The Demo class should instantiate a Reservation object and display a menu to the user that will allow for the following actions: 1. Add a new passenger to the reservation system 2. Insert a new passenger after the passenger that is currently pointed o If a passenger is being added/inserted to an empty reservation list, that passenger should then be set to be the one that is currently pointed. 3. Print the contents of the reservation list 4. Display the current passenger (including name, phone, seat and cost) o When displaying the current passenger for the first time, the first passenger in the reservation list should be displayed. To accomplish this, create a Passenger reference variable and assign it the first Passenger in the Reservation 5. Cancel the current reservation (meaning that remove the current passenger). o o Display a message that the reservation of that specific passenger is canceled. When removing the current passenger, the new current passenger will be the passenger that directly follows the removed passenger. 6. Skip to the next passenger o If you are at the end of the reservation list, the next Passenger should be the first Passenger in the reservation list. 7. Return to the previous passenger 8. Exit Dogor 2 Validate the user's input for the menu option. The user should be required to enter a valid menu option before advancing. CSC 249 Data Structures and Algorithms Project - 1 (Reservation System) If any of the options chosen would not work due to there being no applicable passengers in the reservation list, an appropriate error message should be displayed. The user should be allowed to repeatedly select menu options until they choose to Exit. Instructions Use the following information to create a program for a train reservation system. Your program should contain three separate classes: a Passenger class, a Reservation class, and a Demo class. In this program, the Reservation class will function as a doubly linked list that contains Passenger objects. The Demo class will be used to make modifications to the Reservation list. Passenger Class This class should contain the following fields: name: String phone: String seat: int o This is the seat number assigned cost: int o This is the cost the passenger paid (each seat may have a different price) next: Passenger o This is a reference to the passenger that follows this passenger in the list • previous: Passenger o This is a reference to the passenger that precedes this passenger in the list The Passenger class should contain the appropriate getters and setters for these attributes, a no-arg constructor, and a constructor that accepts the following arguments: name, phone, seat and cost. Reservation Class This class will act as our doubly linked list. This class should contain the following attributes: • head: Passenger o A dummy node (a blank passenger object that will represent the first passenger in the • head: Passenger o Page: 1 A dummy node (a blank passenger object that will represent the first passenger in the reservation list) tail: Passenger o A dummy node (a blank passenger object that will represent the last passenger in the reservation list) size: int o The number of reservations in the reservation list CSC 249 Data Structures and Algorithms Project - 1 (Reservation System) Note: Make sure to review the section in your book on Dummy Nodes - they should help simplify the logic required for methods that operate on the Reservation class. The Reservation class should contain a no-arg constructor which initializes the size, head and tail attributes. This no-arg constructor should also properly connect the head and tail nodes of the doubly linked list. The Reservation class should also contain the following methods: • A method that accepts a Passenger object and adds it to the end of the reservation list. A method that accepts two Passenger objects (a new Passenger to be added, and a Passenger that is currently pointed in the reservation list). This method will insert the new Passenger into the reservation list at the position directly after the Passenger that is currently pointed.. • A method that accepts a Passenger object, returns nothing, and removes the Passenger from the reservation list. • A toString method that prints out the contents of the reservation list. This toString method should also calculate and display the number of passengers in the reservation list, as well as the total cost • A toString method that prints out the contents of the reservation list. This toString method should also calculate and display the number of passengers in the reservation list, as well as the total cost paid by the passengers in the list. Demo Class This class will serve to accept user input and manipulate the Reservation doubly linked list. The Demo class should instantiate a Reservation object and display a menu to the user that will allow for the following actions: 1. Add a new passenger to the reservation system 2. Insert a new passenger after the passenger that is currently pointed o If a passenger is being added/inserted to an empty reservation list, that passenger should then be set to be the one that is currently pointed. 3. Print the contents of the reservation list 4. Display the current passenger (including name, phone, seat and cost) o When displaying the current passenger for the first time, the first passenger in the reservation list should be displayed. To accomplish this, create a Passenger reference variable and assign it the first Passenger in the Reservation 5. Cancel the current reservation (meaning that remove the current passenger). o o Display a message that the reservation of that specific passenger is canceled. When removing the current passenger, the new current passenger will be the passenger that directly follows the removed passenger. 6. Skip to the next passenger o If you are at the end of the reservation list, the next Passenger should be the first Passenger in the reservation list. 7. Return to the previous passenger 8. Exit Dogor 2 Validate the user's input for the menu option. The user should be required to enter a valid menu option before advancing. CSC 249 Data Structures and Algorithms Project - 1 (Reservation System) If any of the options chosen would not work due to there being no applicable passengers in the reservation list, an appropriate error message should be displayed. The user should be allowed to repeatedly select menu options until they choose to Exit.
Expert Answer:
Answer rating: 100% (QA)
Based on the instructions provided we are to create a simple train reservation system consisting of three classes Passenger Reservation and Demo Below is a sample implementation in Java for these clas... View the full answer
Related Book For
Quantitative Investment Analysis
ISBN: 978-1119104223
3rd edition
Authors: Richard A. DeFusco, Dennis W. McLeavey, Jerald E. Pinto, David E. Runkle
Posted Date:
Students also viewed these programming questions
-
Use the following information to complete Keith and Jennifer Hamilton's 2015 federal income tax return. If information is missing, use reasonable assumptions to fill in the gaps. Form 1040,...
-
Based upon the (Instructor-provided) five-year pro forma operating cash flow analysis, extend that exhibit to show after-debt service cash flows partitioned into those flowing to the limited partners...
-
Does the customer buying process end when a customer buys some merchandise? Explain your answer.
-
The T accounts for equipment and the related accumulated depreciation for Trevis Corporation are as follows: In addition, Trevis's income statement reported a loss on the sale of equipment of $1,500....
-
Citric acid (C 6 H 8 O 7 ) is used in the preparation of many foods, pharmaceuticals, soft drinks, and personal-care products. Although it can be recovered by concentration and crystallization from...
-
Discuss the place of selling in the marketing mix.
-
Chester Industries manufactures automobile components for the worldwide market. The company has three large production facilities in Virginia, New Jersey, and California, which have been operating...
-
Implement the following circuit on MultiSim using NOR Gate only and make truth table to verify outputs. SW1 SW2 SW3 AND3 AND1 NOTO OR1 OR2 NOTO
-
The following square-planar complexes are what kind of isomers? Half On ionization b.optical O coordination Od geometric elinkage NH
-
Mr . Mokhtar is considering opening a new foundry in Kajang, BB Bangi and Semenyih to produce high - quality product X . He has assembled the following fixed cost and variable cost data: Location...
-
A bank has 4 sites at which checks are processed. The daily capacity for these sites are: A - 6 0 0 0 checks; B - 8 0 0 0 checks; C - 7 0 0 0 checks; D - 9 0 0 0 checks. The bank processes 4 types of...
-
A company needs to determine the optimal replacement policy for a current 1-year-old machine over the next 4 years (n = 4). The company requires that a 6-year-old machine be replaced. The cost of a...
-
In a machine shop, machines are getting breakdown at an average rate of 12 per hour and mean arrival rate follows Poisson distribution. The mean time to repair a machine is 4 minutes and the mean...
-
Pick up a project in your own professional area. Briefly explain what qualifies it to be a 'project'. For this project, explain what one should expect in the Project Execution Plan (PEP/PMP)....
-
The JAW Bottling Company has recently introduced a new beer to the market called HEAVY. It is extra high in calories. It has been developed specifically for those people that enjoy feeling full after...
-
Why should you not model a decision variable as a random variable with a probability distribution?
-
Gary Hansen is a securities analyst for a mutual fund specializing in small-capitalization growth stocks. The fund regularly invests in initial public offerings (IPOs). If the fund subscribes to an...
-
Kenneth McCoin, CFA, is a fairly tough interviewer. Last year, he handed each job applicant a sheet of paper with the information in the following table, and he then asked several questions about...
-
You are examining the results of a regression estimation that attempts to explain the unit sales growth of a business you are researching. The analysis of variance output for the regression is given...
-
Use Rayleigh's method to solve Problem 2.13. Data From Problem 2.13:- Find the natural frequency of the pulley system shown in Fig. 2.56 by neglecting the friction and the masses of the pulleys. 0000...
-
Use Rayleigh's method to solve Problem 2.7. Data From Problem 2.7:- Three springs and a mass are attached to a rigid, weightless bar \(P Q\) as shown in Fig. 2.51. Find the natural frequency of...
-
Determine the effect of self weight on the natural frequency of vibration of the pinned-pinned beam shown in Fig. 2.110. 1 2 M + Uniform beam flexural stiffness = El total weight-mg FIGURE 2.110...
Study smarter with the SolutionInn App