...

View Full Version : coursework help



rachel_d
12-20-2011, 01:07 PM
Hi there,

I've recently been set some coursework to create a TCP client/server inventory program (java) and I'm really confused. I have the client/server code, I just don't know how to meet the criteria as follows. If someone could point me in the right direction, it would be much appreciated as I'm really stressing out. Thanks!

A CD shop with an inventory containing the following items:

item code CD name Artist Name Price Quantity in stock.

The inventory should be read by a TCP server program from a file separated by tabs. (text file)

The server waits for client requests and transmits the inventory if an "I" is received.
If a "B" followed by an item code is received, the quantity in stock should be updated to reflect that an item has been bought.

A client program should connect to the server, download the inventory and display it to the customer.

The customer should be able to buy any item by typing in the item's code. A shopping trolley should keep track of the items selected by the customer and give a total price for the whole transaction.


:confused:

DanInMa
12-20-2011, 03:20 PM
not to be a pain, but are you asking for someone to write this for you or what do you need?
Refer to the forum rules #1.5 - http://www.codingforums.com/rules.htm

that being said, if you need some assistance with a specific problem in code you've already tried you should probably post the code you are struggling with so someone can assist you

rachel_d
12-20-2011, 04:01 PM
yeah i understand that. i'm just looking for guidance as to how I would go about each part.

1) for instance "The inventory should be read by a TCP server program from a file separated by tabs. (text file)"

i'm not sure how to seperate the artist/quantity etc. by tabs inside the text file...

2) The server waits for client requests and transmits the inventory if an "I" is received.
If a "B" followed by an item code is received, the quantity in stock should be updated to reflect that an item has been bought.

i'm really not sure what method is used to enable the client to type "I" to transmit the entry. I'm guessing BufferedReader is used but i'm not sure how to do this. And same goes with the "B" affecting quantity of stock.

I'm not asking you to do the work for me, I'm just asking for a few pointers to set me on my way. My teacher isn't the best of help and I have asked but I still don't really understand. Thankyou R

alykins
12-20-2011, 05:46 PM
Java tcp (http://systembash.com/content/a-simple-java-tcp-server-and-tcp-client/) stuff

Java file (http://docs.oracle.com/javase/tutorial/essential/io/file.html) stuff

format string "case" (http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#toUpperCase())

Java switch and case (http://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html) stuff

Java escape sequences (http://stackoverflow.com/questions/1367322/what-are-all-the-escape-characters-in-java)



tcp client listen for server tcp
convert incoming byte[] to string and to uppercase
receive message and do something based on case statement
read/write file
send message back


should be more than enough to get you started

rachel_d
12-20-2011, 06:02 PM
Thankyou alykins! =]

DanInMa
12-21-2011, 04:35 PM
Thankyou alykins! =]

see, there you go :). I wish you luck! :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum