DSA - Assignment 5
DSA - Assignment 5
Return to Assignments
DSA - Assignment 1
Train Booking System
using linked list data structure
INTRODUCTION
Your first assignment in this block will be using linked list data struture for implementing a Train
Booking System (TBS) in Java language.
TBS manages information about Traines, customers and train booking. These information are:
About a train:
1. tcode (string): the code of the train (this should be unique for the train).
2. train_name (string): the name of the train.
3. seat (integer): the number of seats in the train (seat > 0).
4. booked (integer): the number of booked seats in the train (booked >= 0 and booked ≤ seat).
5. depart_time (double): The depature time of the train (depart_time >= 0).
6. depart_place (string): The place of departure of the train.
About a customer:
1. ccode (string): the code of the customer (this should be unique for the customer).
2. cus_name (string): the name of the customer.
3. phone (string): The phone number of the customer (must contain digits only).
About Booking:
1. tcode (string): the code of the train to be booked.
2. ccode (string): the code of the customer.
3. seat (integer): the number of seats to be booked on the train.
YOUR TASKS
You should use 3 linked lists, each one is used to store data for trains, customers or train booking items.
You should create linked lists from scratch, do not use list structures available in java like ArrayList,
Vector or LinkedList classes.
On running, your program displays the menu as below:
file:///D:/DATA/FPT/CSD201/CSD201_learning_website/assignments/1.5.train.html 1/4
1/17/25, 2:32 PM DSA - Assignment 1
TASKS EXPLANATION
B03 | Sug | 12 | 3 | 11 | PA
B01 | Mil | 10 | 5 | 5.7 | PC
B02 | App | 5 | 2 | 4 | PB
B05 | Roo | 7 | 6 | 15 | PE
B07 | Bee | 11 | 3 | 12 | PF
B04 | Boo | 9 | 5 | 5 | PD
The first line means that: tcode = B03, train_name = Sug, seat = 12, booked = 3, depart_time = 11 and
depart_place = PA.
The task of this option is to read rows from the text file and add to the end of the list. If the list is not
empty, then the program asks the user if he/she wants to keep the existing data or not.
tcode|Train_name|Seat|booked|depart_time|depart_place|available_seat
-------------------------------------------------------------------
B03 | Sug | 12 | 3 | 11 | PA | 9
B01 | Mil | 10 | 5 | 5.7 | PC | 5
B02 | App | 5 | 2 | 4 | PB | 3
B05 | Roo | 7 | 6 | 15 | PE | 1
B07 | Bee | 11 | 3 | 12 | PF | 8
B04 | Boo | 9 | 5 | 5 | PD | 4
file:///D:/DATA/FPT/CSD201/CSD201_learning_website/assignments/1.5.train.html 2/4
1/17/25, 2:32 PM DSA - Assignment 1
which deletes the node whose info contains the train with tcode = xCode.
Allow a user to input the tcode to be deleted and then delete the train having that tcode.
1.9. Delete the node before the node having tcode = xCode
Allow a user to input xCode and delete the node before the node having tcode = xCode.
The first line means that: ccode = C03, name = Hoa, phone = 1902
Submission Requirements
Create the directory with a name like <class>-<name><roll number>-ASS1, e.g.
SE0508-QuangTV00456-AS1 (1)
The (1) directory contains the following files:
1. The run.bat file to run your program.
2. Your source code files.
3. train.txt and customer.txt files.
file:///D:/DATA/FPT/CSD201/CSD201_learning_website/assignments/1.5.train.html 3/4
1/17/25, 2:32 PM DSA - Assignment 1
file:///D:/DATA/FPT/CSD201/CSD201_learning_website/assignments/1.5.train.html 4/4