Product.java 747B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * Created by leon on 1/10/18.
  3. */
  4. public class Product {
  5. private double price;
  6. private int quantity;
  7. private String id;
  8. public Product(String id, double price, int quantity) {
  9. this.id = id;
  10. this.price = price;
  11. this.quantity = quantity;
  12. }
  13. public String getId() {
  14. return this.id;
  15. }
  16. public double getPrice() {
  17. return this.price;
  18. }
  19. public void changePrice(double newPrice) {
  20. price = newPrice;
  21. }
  22. public int getQuantity() {
  23. return this.quantity;
  24. }
  25. public void changeQuantity(int amount) {
  26. if (amount >= 0) {
  27. this.quantity += amount;
  28. } else {
  29. this.quantity -= amount;
  30. }
  31. }
  32. }