This is my school assignment. I need an inventory system which auto-updates product ID when users key-in a new product. I created an array of object named Product with 4 attributes(name,ID,price,quantity). The ID should not need a user input.
This part is in the input() method,which is in a different class from the Object.I didn't pass the ID to the object class like I did to the other three attributes.
x[i] = new Product(name,price,stock);
id = x[i].setID();
part of the object class:
/**
* Constructor
*/
public Product(){
id = 0; name = ""; price = 0.00; quantity = 0;
}
public Product( String n, double p, int q){
setName(n); setPrice(p); setQuantity(q);
}
public void setID(){
this.id = id++;
}
Thank you.