Results 1 to 3 of 3
- 05-02-2010, 11:29 PM #1
Member
- Join Date
- Mar 2010
- Posts
- 49
- Rep Power
- 0
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 04:11 PM.
-
Hello!
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 got an assign for tomorrow morning...
OK...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,....
I don't see this one here. Have you created this but have no problem with it and so didn't post it?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.
1) What errors?Please check me My Inventory class,, i got some 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!
- 05-03-2010, 12:42 AM #3
Member
- Join Date
- May 2010
- Posts
- 9
- Rep Power
- 0
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
-
Help with Inventory Program, Please
By NewKidjava in forum New To JavaReplies: 4Last Post: 08-21-2009, 11:09 AM -
E:\IT 215 Java Programming\Inventory.java:36: class, interface, or enum expected
By tlouvierre in forum Advanced JavaReplies: 16Last Post: 05-28-2009, 03:41 PM -
E:\IT 215 Java Programming\public class Inventory.java:39: class, interface, or enum
By tlouvierre in forum New To JavaReplies: 14Last Post: 05-28-2009, 05:44 AM -
adding GUI to Inventory
By voyager91 in forum New To JavaReplies: 8Last Post: 02-01-2009, 05:20 AM -
Inventory part 2 help please
By badness in forum New To JavaReplies: 1Last Post: 12-12-2007, 07:51 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks