COMP2396
Loading...
Searching...
No Matches
CmdCheckProductInfo.java
Go to the documentation of this file.
1public class CmdCheckProductInfo implements Command {
2 @Override
3 public String execute(VendingMachine v, String[] cmdParts) {
4 // sample output:
5 //Pepsi: Price = 5, Quantity = 3.
6 String productName = cmdParts[1];
7 Product product = v.getProduct(productName);
8 if (product != null) {
9 return product.getName() + ": Price = " + product.getPrice() + ", Quantity = " + product.getQuantity() + ".";
10 } else {
11 //not required for the assignment
12 return "Product not found!";
13 }
14 }
15}
String execute(VendingMachine v, String[] cmdParts)
int getQuantity()
Definition Product.java:24
int getPrice()
Definition Product.java:20
String getName()
Definition Product.java:16
Product getProduct(String name)