Java Help
nel
Member Posts: 2,859 ■□□□□□□□□□
Hello me again yet again!!!
Was hoping someone could give me advice on some coding im trying to do for uni.
To give you an overall view: im trying to create a little inventory program where there is a server interface and a client interface. Now on the client interface it displays a menu with several options and the server interface displays whats in the repository. Upon choosing one of those options it sends the appropriate method request to the server handler. What im trying to do is add a function where i can dynamically add items to the repository. This is already in place from the code i have from uni using the server.put class and method. however i cant seem to add them to it
I have botched together this method which *i think* will add new items to the repository:
Now on the client side i have added code to send the serialno, description,stock and location. Shown below:
So by my understanding that should send the values input by the user.
But my problem is how do i insert the data sent by the user into the server repository?
As you can see from the first "additem" method there is a "server.put" which relates to a method in the server class which adds things to the repository. ive looked in the server class and noticed the put method has only two objects. Originally i was trying to fit the 4 objects (serial description,location and stock) in there but as you can see from my first method i have tried inserting just two of these and they still dont show in the server interface.
Any idea's on this? SOrry if im vague im not too familar with the correct terminology?
Thanks
Was hoping someone could give me advice on some coding im trying to do for uni.
To give you an overall view: im trying to create a little inventory program where there is a server interface and a client interface. Now on the client interface it displays a menu with several options and the server interface displays whats in the repository. Upon choosing one of those options it sends the appropriate method request to the server handler. What im trying to do is add a function where i can dynamically add items to the repository. This is already in place from the code i have from uni using the server.put class and method. however i cant seem to add them to it
I have botched together this method which *i think* will add new items to the repository:
public String addItem(){ String serialNo = (String) receive(); String description = (String) receive(); Integer stock = (Integer) receive(); String location = (String) receive(); //String dateTime = (String) receive(); //creates new stockitem from stockitem class StockItem item = new StockItem(serialNo, description, stock, location) ; // creates new serial number serialNo = new Integer(server.getReposSize() + 1).toString(); //Must make item code unique to this client serialNo = serialNo + this.hashCode(); while (server.exists(serialNo)){ serialNo = new Integer(server.getReposSize() + 1).toString(); } server.put(serialNo, item); return "Item added"; }
Now on the client side i have added code to send the serialno, description,stock and location. Shown below:
// This adds new item if (choice.equals("n")){ //Add new Item send("addItem"); // remote method //Send Serial Number System.out.println("Item Serial no.\t"); String serialNo = getString(); send (new Integer(serialNo)); // send description System.out.println("Item Description\t"); String description = getString(); send(new String(description)); //Send No. of STock System.out.println("No. Of Stock\t"); String stock = getString(); send (new Integer(stock)); // send Item Location System.out.println("Item Location\t"); String location = getString(); send(new String(location)); send(getDateTime()); //Time of transaction System.out.println(receive()); //Find out the status of our command }
So by my understanding that should send the values input by the user.
But my problem is how do i insert the data sent by the user into the server repository?
As you can see from the first "additem" method there is a "server.put" which relates to a method in the server class which adds things to the repository. ive looked in the server class and noticed the put method has only two objects. Originally i was trying to fit the 4 objects (serial description,location and stock) in there but as you can see from my first method i have tried inserting just two of these and they still dont show in the server interface.
Any idea's on this? SOrry if im vague im not too familar with the correct terminology?
Thanks
Xbox Live: Bring It On
Bsc (hons) Network Computing - 1st Class
WIP: Msc advanced networking
Bsc (hons) Network Computing - 1st Class
WIP: Msc advanced networking
Comments
-
nel Member Posts: 2,859 ■□□□□□□□□□Anyone? Or even an indication if im doing something obviously wrong?Xbox Live: Bring It On
Bsc (hons) Network Computing - 1st Class
WIP: Msc advanced networking