Hi, I have an assignment due in a couple of weeks and really need some help with it. I have started it allready and all the code I have written is bellow. I'm very new to
java and without the help of my lecturer's am finding this assignment quite hard so ANY help would be apreciated.
This is the assignment:
The assignment is about delivering an on-line (airline JavaJet) booking system. The customer should be able to request a departures time table (2 planes leave per day), make reservations, cancel reservations (only the client who has made the reservation), buy tickets, enquire about free places on a flight.
The system will make use of datagram Sockets technology and will consist of a server and multiple clients. You are to implement a simple information server and several client objects. You need not worry about producing a graphical user interface. (If you do it will be worth extra marks).
The functionality of the Client is that it should
Be able to connect to the server and register its IP address as a valid user along with the name of the user in order to join the service.
Be able to remove the user from the service (e.g. when disconnecting to execute log-off command).
Be able to send a message to the server specifying the information required: - request departures time table per day (2 planes leave per day), - make reservation, cancel reservation, buy tickets, enquire about free places on a flight.
Be able to asynchronously receive and display messages from the information server that a plane has just became fully booked. The second urgent message is that a fully booked plane has just had a cancellation and now has seats available (when somebody else cancels the booking). This requirement can only be properly achieved through use of multithreading.
The functionality of the Server is that it should
Keep a record (in some form) of all on-line registered participants and their addresses.
To be able to accept new participant registrations and add them to the active participants list.
To be able to accept requests from client to remove itself from its records (log-off only from the computer it has registered first).
To read the pre-prepared airline time table from a text file consisting of multiple lines with the following format:
JavaJet <flight Number> <day.month.year> <hh.mm> <total number of seats> < reserved seats> <seats available>
To receive messages and perform the actions required (book, un-book, sell tickets, send timetable information to the cleint.
To handle multiple client connections concurrently.
Maintain correctly the list of seats available in the booking system.
At the moment my code dosn't really work. When I connect to the server it starts a
thread and then instantly ends it, then the second time it starts it, runs it for one iteration and then ends it, then starts it, runs it for 2 iterations etc. I can't figure out why.
I'm unsure of how to read the timetable from a file and the thing I am most clueless about is how to asynchronously receive and display messages from server to clients.
I also don't understand how to register the client's IP / name with the server and then store it.
Any other general info and help on datagrams and java would REALLY be appreciated. I'm not asking anyone to do this for me!! Just need a little help.
This is the code I have so far. I've only been working on this for about a day.
This is what I have so far for the server:
This is what I have so far for the client:
This is what I have so far for my thread:
Thanks a lot,
J.