• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Network assignment HELP NEEDED

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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> <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.
 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

Layne
 
jambeard lewistrix
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic