Guest User

Untitled

a guest
Sep 26th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. import java.util.Arraylist;
  2.  
  3. public class Database
  4. {
  5. private ArrayList<Product> productList = new ArrayList<>(); //creating a list
  6.  
  7. public class Database() {}
  8. }
  9.  
  10.  
  11.  
  12. public void addproduct(product a)
  13. { //allows a product to be added to list
  14. productList.add(a);
  15. }
  16.  
  17.  
  18. public void removeProduct(String name)
  19. {
  20. for (product a : productList) //allows a product to be removed
  21. {
  22. if(a.getName.equals(name)
  23. productList.remove(a);
  24. }
  25. }
  26.  
  27.  
  28. public int getproductname()
  29. {
  30. int name = noname;
  31. for (product a : ProductList)
  32. {
  33. name = name + a.getproductname();
  34. }
  35. return name;
  36. }
  37.  
  38.  
  39. public int countProducts(int productname)
  40. {
  41. int matches = 0;
  42. for (product a : ProductList)
  43. {
  44. if (a.getbalance() >=product) matches++;
  45. }
  46. return matches;
  47. }
  48.  
  49.  
  50. public int productfind(int proname)
  51. {
  52. for (product a : productList)
  53. {
  54. if(a.getproduct() == proname)
  55. return a;
  56. }
  57. return null;
  58. }
  59.  
  60.  
  61. }
  62.  
  63. }
Add Comment
Please, Sign In to add comment