ProductItem.java 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * Created by leon on 1/10/18.
  3. */
  4. public class ProductItem {
  5. private int productid;
  6. private int productquantity;
  7. private int productprice;
  8. //constructor : sets product id,quantity and description to 0 if no parameters given
  9. public ProductItem()
  10. {
  11. productid=0;
  12. productquantity=0;
  13. productprice=0;
  14. }
  15. //overload constructor : sets product id,quantity and description to whatever parameters given
  16. public ProductItem(int id, int quantity, int pr)
  17. {
  18. productid=id;
  19. productquantity=quantity;
  20. productprice = pr;
  21. }
  22. //sets a new id for productid
  23. public void setid (int newid)
  24. {productid=newid;}
  25. //sets a new id for productquantity
  26. public void setquantity (int newquantity)
  27. {productquantity=newquantity;}
  28. //sets a new id for productdesc
  29. public void setpr (int pr)
  30. {productprice=pr;}
  31. //get function that returns productid
  32. public int getid()
  33. {return productid;}
  34. //get function that returns productquantity
  35. public int getquantity()
  36. {return productquantity;}
  37. //get function that returns productdesc
  38. public int getpr()
  39. {return productprice;}
  40. //method to output ProductId
  41. public void outputid()
  42. {System.out.println("Product Id: " + productid);}
  43. //method to output ProductQuantity
  44. public void outputquantity()
  45. {System.out.println("Product Quantity: " + productquantity);}
  46. //method to output ProductDesc
  47. public void outputpr()
  48. {System.out.println("Price: " + productprice);}
  49. }