• Post Reply Bookmark Topic Watch Topic
  • New Topic

Inventory management system  RSS feed

 
Jordan King
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am building a basic IMS which has two classes. One class, Product, which contains the price, quantity on hand, and identification number, and a second class, Inventory, which takes in products and keeps them all on file. I already have the Product class created. I just don't know how the second class will hold multiple classes inside of itself. The answer is probably simple but I am fairly new to coding so any input would be much appreciated. Thanks guys!! ^_^
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jordan King wrote:I just don't know how the second class will hold multiple classes inside of itself.

Easiest is just a List or Collection, but in your case, since you will probably want to reference by Product ID, the best is probably a Map. Java has a few different types, so I suggest you have a look at them, and read this section of the tutorials before you write any more code because trying to design an IMS without them is going to be VERY hard.

Another thing: quantityOnHand is not really an attribute of your Product class. It should be part of your Inventory class, since presumably that's what you want it for.

The easiest way to think of it is this: A tin of beans doesn't have a "quantity" does it? It's just a tin of beans. But it certainly has a price.

A couple of other things:
Be VERY careful about adding "setters" to your classes. Do you really want to be able to change a Product ID? If you do, you're likely to screw up your entire Inventory class in one fell swoop, since everything will be registered under the OLD ID.
Changing a price, on the other hand, seems quite reasonable.

You might also want to add a 'name' or 'description' to your Product class, since we puny humans find ID numbers a bit tough to deal with.

HIH

Winston
 
Jordan King
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This was very helpful, thanks Winston.
 
Les Morgan
Rancher
Posts: 779
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jordan,

realistically, for anything other than a trivial amount of data you will need a database.

Les
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!