Assignment 1 - de Chan
Assignment 1 - de Chan
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:
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.
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.
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.
The statements in run.bat file may be:
cls
javac Main.java
java Main
pause
del *.class
Compress the folder (1) to .zip (or .rar) file (with the same name) and upload to cms.
Assignment assessment
You will be asked to modify immediately and to explain your assignment in class room to be
sure that you are really the author of the assignment you submitted.