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
-
7. An internet industry in Edmonton has the following characteristics: C = 200+4Q MC = 8Q P= 180-4Q MR = 180-8Q (each firm's total cost function) (firm's marginal cost function) (industry demand...
-
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 financial statements of Shoppers Drug Mart are presented in Appendix A at the end of the book. Instructions (a) What types of current and non-current liabilities were reported in Shoppers'...
-
Presented below is the trial balance of Thompson Ltd. at December 31, 2022. A physical count of inventory on December 31 resulted in an inventory amount of 64,000; thus, cost of goods sold for 2022...
-
What format requirements must be met?
-
Account balances taken from the ledger of High Flying Logistics Co. on December 31, 2011, follow: Cash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....
-
13.Felicia and Rocky met at a training convention and subsequently became lovers. They had children named Enrico and Euriz. One night while on his way home, Rocky met his end when his car collided...
-
Liquid reaction A --> 2B is taking place in a steady state packed bed reactor that has total available packing area (A) of 10 m. The density (p) and packing surface (a) of the catalyst per volume are...
-
You are here required to compute Throttle Corporation's 2020 cash flow from operating activity; cash flow from investing activity; cash flow from financing activity. Place your answer at the bottom...
-
There are emails, newsletters, and short progress notes that teachers can use to communicate with parents daily or weekly. What are some other ways to physically involve parents in classroom...
-
Yancey Productions is a film studio that uses a job-order costing system. The company's direct materials consist of items such as costumes and props. Its direct labor includes each film's actors,...
-
Stakeholders are the individuals and groups that are affected by and can affect what a team does or produces. A team's stakeholders usually present the team with a variety of wonderful opportunities...
-
Compare and contrast the organizational structure of theHarley Davisons and Toyotafirms and discuss the advantages and disadvantages of each structure. Web pages:...
-
Describe the results of implementing the lesson/activity with the students, including student assessment results. Discuss the long-term results you would expect to see if you differentiated the...
-
Alberto sells 2 product types with the following data: Product A: Sales price $4/unit, variable cost $2/unit Product B: Sales price $4/unit, variable cost $3/unit Fixed Costs: $150,000 Assuming a...
-
True & False The basis of an asset must be reduced by the depreciation allowable, 2. Adjusted gross income (AGI) is the basis for a number of phase-outs of deductions. 3. A change to adjusted gross...
-
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...
-
The relative co-efficient of performance of a heat engine is the ratio of (a) The theoretical COP to the actual COP (b) The actual COP to the theoretical COP (c) The theoretical COP to the ideal COP...
-
The advantage of the vapour-compression refrigeration system over the absorption refrigeration system is that (a) The charging of the refrigerant is quite simple (b) The space requirement for...
-
Pick out the correct relation between the \(\mathrm{COP}\) of a refrigerator \(\left(\mathrm{COP}_{\mathrm{R}} ight)\) and that of the heat pump \(\left(\mathrm{COP}_{\mathrm{HP}} ight)\) (a)...
Study smarter with the SolutionInn App