Skip to content

Instantly share code, notes, and snippets.

@vslala
Created September 9, 2016 09:25
Show Gist options
  • Select an option

  • Save vslala/868529cf35c5608a4861ce57049826c7 to your computer and use it in GitHub Desktop.

Select an option

Save vslala/868529cf35c5608a4861ce57049826c7 to your computer and use it in GitHub Desktop.
package collections.shoppingcart;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author Varun Shrivastava (vslala)
*/
public class Products {
private final List<Product> products = new ArrayList<Product>();
public Products () {
this.initStoreItems();
}
public List<Product> getProducts() {
return products;
}
public void initStoreItems() {
String [] productNames = {"Lux Soap", "Fair n Lovely", "MTR"};
Double [] productPrice = {40.00d, 60.00d, 30.00d};
Integer [] stock = {10, 6, 10};
for (int i=0; i < productNames.length; i++) {
this.products.add(new Product(i+1, productNames[i], productPrice[i], stock[i]));
}
}
}
@vslala

vslala commented Sep 9, 2016

Copy link
Copy Markdown
Author

This class is simple used to init the store items and maintain the database in an arraylist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment