- package prac4;
- public class Inventory {
- public static void main(String[] args) {
- Product p1 = new Product(1, "ssoap", 40, "household", 45);
- Product p2 = new Product(2, "goil", 50, "household", 45);
- Product p3 = new Product(3, "mtv", 7000, "electronics", 100);
- Product p4 = new Product(4, "xrefrigerator", 20000, "electronics", 45);
- Product p5 = new Product(5, "mmobile", 3500, "gadgets", 65);
- Product[] prods = {p1,p2,p3,p4,p5};
- int count1 = Inventory.updateProductQuantity(prods, 55);
- System.out.println("Updated count "+count1);
- Product[] prods1 = Inventory.getAllProductsProducttypeCost(prods, "household");
- for(Product prod : prods1)
- {
- if(prod!=null)
- {
- System.out.println(prod.getProductname()+" "+prod.getProductcost()+" "+prod.getProductquantity()+" "+prod.getProducttype());
- }
- }
- }
- public static int updateProductQuantity(Product[] prd, int st)
- {int count=0;
- for(int i=0;i<prd.length;i++)
- {
- if(prd[i].getProductquantity()<100)
- {
- //prd[i].setProductquantity(55);
- count++;
- }
- }
- return count;
- }
- public static Product[] getAllProductsProducttypeCost(Product[] pr,String st)
- {int cnt=0;
- for(int i=0;i<pr.length;i++)
- {
- if(pr[i].getProductcost()<1000)
- {
- cnt++;
- }
- }
- Product[] prs=new Product[cnt];
- int j=0;
- for(int i=0;i<pr.length;i++)
- {
- if(pr[i].getProductcost()<1000)
- {
- prs[j]=pr[i];
- j++;
- }
- }
- return prs;
- }
- }
[text] prac4
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: