Product.java 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * Created by leon on 1/10/18.
  3. */
  4. public class Product {
  5. private double price;
  6. private String id;
  7. private int x;
  8. private int quantity;
  9. private String name;
  10. //private Map<Integer, Product> productMap;
  11. public Product(){
  12. }
  13. public Product(String id, double price, int quantity){
  14. this.id = id;
  15. this.price = price;
  16. this.quantity = quantity;
  17. }
  18. public void setPrice(double newPrice){
  19. price = newPrice;
  20. }
  21. public double getPrice(){
  22. System.out.println(price);
  23. return price;
  24. }
  25. public String setId(String newId){
  26. id = newId;
  27. System.out.println(id);
  28. return id;
  29. }
  30. public String getId(){
  31. System.out.println(id);
  32. return id;
  33. }
  34. public void setQuantityOfItem(int x){
  35. this.x = x;
  36. System.out.println(this.x);
  37. }
  38. public int getQuantityOfItem(){
  39. System.out.println("You have " + x + "of this item.");
  40. return x;
  41. }
  42. }