Question: Data Structures; Java programming language; Coding; Singly linked list. A FULLY SUSTAINABLE CITY THE SPINE CONNECTS CITY MODULES In this project we will simulate this

Data Structures; Java programming language; Coding; Singly linked list. Data Structures; Java programming language; Coding; Singly linked list. A FULLY SUSTAINABLECITY THE SPINE CONNECTS CITY MODULES In this project we will simulatethis metro-train, by using Linked Lists as a suitable data-structure to storeinformation about trains, passengers, service timings, cost of journey etc. You project

A FULLY SUSTAINABLE CITY THE SPINE CONNECTS CITY MODULES In this project we will simulate this metro-train, by using Linked Lists as a suitable data-structure to store information about trains, passengers, service timings, cost of journey etc. You project implements three classes namely Node, List and Solution. The following provides an API for your project. Node int ticketID; int paxID; int journeyDate; int srcModule; int destModule; String paxName; Node next; Node() Node.) Description // a unique ticket id; // Passenger ID number: // journey date DDMMYYYY; // takes values between 1 and 255 // takes values between 1 and 255 // Name of the passenger // Node next // default constructor //override constructor as necessary. You can edit the params as needed. //returns a String with the contents of the Node as follows: ticketID, paxID, journeyDate, srcModule, destModule, paxName. String toString() The following is the API for the List class. This implements a Singly Linked List consisting of Nodes from the Node class. List Node Head; int size; Description // Anchors the Head of the List // Maintains the size of the List List(); // default constructor insert (Node N) // inserts the node N in the correct position, ordered by the date. e.g. datel is 14022021; date2 is 01032021. datel appears before date2. Assume all months have exactly 30 days. There are 12 months in a year. If dates are equal (we assume inserting at the beginning). //removes the first node with matching PaxID void remove (PaxID) //Computes the cost of ALL journeys for a passenger with Pax ID. Here is how this is computed. int cost (PaxID) Journey cost = Math.abs(srcModule - destModule) * 5. //example srcModule=3, destModule=5. Journey Cost = 10. void printl (Pax ID) void print2 (journeyDate) 1/searches for PaxID in the list. Prints ALL nodes with PaxID. 1/searches for journeyDate in the list. Prints ALL nodes with journeyDate. //searches for srcModule in the list. Prints ALL nodes with srcModule. // searches for destModule in the list. Prints ALL nodes with destModule. void print3(srcModule) NOTE: print methods call Node.toString() as necessary. void print3 (destModule) The following is the API for the Solution class. This class implements the main method, makes appropriate data Input/Output calls and implements data structures and all necessary method calls. Solution //Attributes NA main() Description Not applicable Implements the main method; reads data from console, processes information and make appropriate calls as necessary. Sample Input Here is a sample input 1 1225 101 10022021 3 5 Ahmed Baloshi 1 1226 101 11022021 5 8 Ahmed Baloshi 1 1227 101 12022021 8 3 Ahmed Baloshi 3 101 2 101 4 101 Sample Output For the above sample input, the following would be printed on the console. 50 1226 101 11022021 5 8 Ahmed Baloshi 1227 101 12022021 8 3 Ahmed Baloshi Explanation 1 1225 101 10022021 3 5 Ahmed Baloshi 1 1226 101 11022021 5 8 Ahmed Baloshi 1 1227 101 12022021 8 3 Ahmed Baloshi The line starting with integer 1 indicates that insert would be called. No Output is generated for the insert call. 3 101 The line starting with integer 3 indicates that cost method would be called The program computes the cost for all journeys taken by Passenger with paxID = 101. In the list, there are 3 nodes with paxID = 101. Node with ticketID=1225 has a journey cost = Math.abs (3-5) * 5 = 10 Node with ticketID=1226 has a journey cost = Math.abs(5-8) * 5 = 15 Node with ticketID=1227 has a journey cost = Math.abs (8-3) * 5 = 25 Hence total cost = 10+15+25=50 50 will be displayed on the console 2 101 The line starting with integer 2 indicates that the first node with paxID=101 will be removed from the list. No output is generated. This removes the node that contains the following information 1 1225 101 10022021 3 5 Ahmed Baloshi 4 101 The line starting with integer 4 indicates that all passenger details for PaxID=101 will be printed on console separate by new line character at the end of each line. 1226 101 11022021 5 8 Ahmed Baloshi 1227 101 12022021 8 3 Ahmed Baloshi Similar to the above, your program implements the following commands: Legend for the acceptable commands: 1. insert details for a new node 2 removes node from list 3 computes the cost of ALL journeys for this PaxID and displays the total. 4. prints All nodes with PaxID. 5. prints ALL nodes with journeyDate. 6. prints ALL nodes with srcModule. 7. prints ALL nodes with destModule

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!