Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Network assignment HELP NEEDED

Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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> <> <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,

Posts: 3785
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

jambeard lewistrix
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic