Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arraylist;
- public class Database
- {
- private ArrayList<Product> productList = new ArrayList<>(); //creating a list
- public class Database() {}
- }
- public void addproduct(product a)
- { //allows a product to be added to list
- productList.add(a);
- }
- public void removeProduct(String name)
- {
- for (product a : productList) //allows a product to be removed
- {
- if(a.getName.equals(name)
- productList.remove(a);
- }
- }
- public int getproductname()
- {
- int name = noname;
- for (product a : ProductList)
- {
- name = name + a.getproductname();
- }
- return name;
- }
- public int countProducts(int productname)
- {
- int matches = 0;
- for (product a : ProductList)
- {
- if (a.getbalance() >=product) matches++;
- }
- return matches;
- }
- public int productfind(int proname)
- {
- for (product a : productList)
- {
- if(a.getproduct() == proname)
- return a;
- }
- return null;
- }
- }
- }
Add Comment
Please, Sign In to add comment