Product.java 878B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. * Created by leon on 1/10/18.
  3. */
  4. public class Product {
  5. // Create a product class which has a price, id, and quantity on hand
  6. private int price;
  7. private String id;
  8. private int onHand;
  9. public Product(int startPrice, String startId, int startOnHand){
  10. this.price = startPrice;
  11. this.id = startId;
  12. this.onHand = startOnHand;
  13. }
  14. public int getPrice() {
  15. return this.price;
  16. }
  17. public String getId() {
  18. return this.id;
  19. }
  20. public int getOnHand() {
  21. return this.onHand;
  22. }
  23. public int changePrice(int newPrice) {
  24. this.price = newPrice;
  25. return price;
  26. }
  27. public int addOnHand(int supply) {
  28. this.onHand = this.onHand + supply;
  29. return onHand;
  30. }
  31. public int totalValue(){
  32. return this.onHand * this.price;
  33. }
  34. }