Java Help - Part 2 :D

nelnel Member Posts: 2,859 ■□□□□□□□□□
Yes thats right baby im back for more help :D ..This is becoming worse than a van damme film icon_lol.gif

Anyway, after getting passed issues ive previously posted i am now at the final part which i need to fix before im complete so im pretty much 98% of the way there.

Now, i have the method below:
public String addItem(){
    String serialNo = (String) receive();
    String desc = (String) receive();
    Integer stock = (Integer) receive();
    String location = (String) receive();
    String dateTime = (String) receive();
 
    // creates new serial number
    //serialNo = new Integer(server.getReposSize() + 1).toString();
 
    //creates new stockitem from stockitem class
    StockItem item = new StockItem(serialNo, desc, stock, location) ;
 
     if (item == null)
      return "Item does not exist";
 
    //Lock the object
    item = (StockItem) server.lock(serialNo);
    if (item != null){
      String status ="";
 
      //Carry out deposit on the locked account
      if (item.addItem(stock.intValue(),dateTime))
        status = "Stock Added";
      else
        status = "Failed to add new stock";
     server.unlock(serialNo);
     return status;
 
    
}
server.put(serialNo, item);
return "Item added";
}

Basically the client inputs enteries on the client interface and they show in the server interface using the "put" method in my server class. You can see from "server.put(serialNo, item);" This enters the serial no (this shows on the server interface OK) but the item is returned as "null". i believe it has something to do with the line "if (item.addItem(stock.intValue(),dateTime))" ( i copied this from a challenge we had to do previously at uni).

So how do i put the recieve data for the item object into the server.put? i assume its the same way but i cant figure the code in "if (item.addItem(stock.intValue(),dateTime))" to do what i need.

Any help?

Thanks
Xbox Live: Bring It On

Bsc (hons) Network Computing - 1st Class
WIP: Msc advanced networking
Sign In or Register to comment.