daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest Sep 26th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top