File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Network assignment HELP NEEDED Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Network assignment HELP NEEDED" Watch "Network assignment HELP NEEDED" New topic
Author

Network assignment HELP NEEDED

jambeard lewistrix
Greenhorn

Joined: Aug 16, 2005
Posts: 14
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.
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 686
Rather large question.
I suggest you break it up into smaller questions/problems and solve them one at a time.
As an aid to finding problems, add println() statements to your code to show where it is executing and what the contents of key variables is.
Then you can post them so we can see how the program is working.

Good luck.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
It will also help you be more organized if you format your code using commonly accepted standards. For example, it is a common convention to indent the group of statements that are enclosed in { and }. This will help you and us both to be able to read your code more easily.

Layne


Java API Documentation
The Java Tutorial
jambeard lewistrix
Greenhorn

Joined: Aug 16, 2005
Posts: 14
I do indent my code it's just that when I cut and pasted the code from something it all went a bit wrong! sorry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Network assignment HELP NEEDED