Created
September 9, 2016 09:25
-
-
Save vslala/868529cf35c5608a4861ce57049826c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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])); | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This class is simple used to init the store items and maintain the database in an arraylist.