Results 1 to 3 of 3
  1. #1
    javanew is offline Member
    Join Date
    Mar 2010
    Posts
    49
    Rep Power
    0

    Default Please help me with my inventory class

    Hi, please i want your help ,,,,!!
    I got an assign for tomorrow morning...
    I should have Inventory class :
    Inventory class :
    Constructor : one argument that specifies the max number of stock Items,
    and Inventory class contains method like add , remove,setQunatitym,setPrice,....
    Last edited by javanew; 05-03-2010 at 05:11 PM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by javanew View Post
    Hi, please i want your help ,,,,!!
    Hello!


    I got an assign for tomorrow morning...
    Just so you know, posting deadlines often has the opposite effect here as no one likes to feel rushed least of all the volunteers who help out here. Again I'm stating this for your benefit.


    I should have Inventory class :
    Inventory class :
    Constructor : one argument that specifies the max number of stock Items,
    and Inventory class contains method like add , remove,setQunatitym,setPrice,....
    OK...


    I also must have a StockItem class (abstract class) ,
    its attributes id,desciption,name,pirice ,quanity,,
    and 3 classes inherits the StockItem class clothes , food, electric device.
    I don't see this one here. Have you created this but have no problem with it and so didn't post it?


    Please check me My Inventory class,, i got some errors !! :
    1) What errors?
    2) What lines cause the errors?
    3) Do the instructions state that Inventory should subclass JFrame? Even if I were to create a GUI with this, I would avoid making Inventory a part of the user interface but instead have it part of the model. So I guess I'm saying that unless your instructions specifically told you to do this, doing it this way (I believe) is in error.

    Much luck!

  3. #3
    gbtimmon is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default hello

    I'm really confused be your work... maybe refactor before you post next time (the price of your dress is sugar? Interesting...) Also i don't know what the Dress class is but I'm assuming it extends StockItem.

    It looks like your calling s[2] even though you only set the size of your StockItem array to 2. remember that array start at pointer 0 so an array of size 2 only contains the items 0 and 1, making it size three will give you items 0,1 and 2.

    On top of that, i don't believe that building a array of objects typically constructs the objects for you, it only assigns the memory space for the array's memory adress index and leaves the pointers null. (thus why you're getting null pointers!) Regardless, constructing each object one by one will fix this.
    thus you need to write
    s[0] = new StockItem();
    s[1] = new StockItem();
    etc...

    I hope this helps.

Similar Threads

  1. Help with Inventory Program, Please
    By NewKidjava in forum New To Java
    Replies: 4
    Last Post: 08-21-2009, 12:09 PM
  2. Replies: 16
    Last Post: 05-28-2009, 04:41 PM
  3. Replies: 14
    Last Post: 05-28-2009, 06:44 AM
  4. adding GUI to Inventory
    By voyager91 in forum New To Java
    Replies: 8
    Last Post: 02-01-2009, 06:20 AM
  5. Inventory part 2 help please
    By badness in forum New To Java
    Replies: 1
    Last Post: 12-12-2007, 08:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •