COMP2396
Loading...
Searching...
No Matches
CmdCheckProductInfo.java
Go to the documentation of this file.
1
public
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
}
CmdCheckProductInfo
Definition
CmdCheckProductInfo.java:1
CmdCheckProductInfo.execute
String execute(VendingMachine v, String[] cmdParts)
Definition
CmdCheckProductInfo.java:3
Product
Definition
Product.java:1
Product.getQuantity
int getQuantity()
Definition
Product.java:24
Product.getPrice
int getPrice()
Definition
Product.java:20
Product.getName
String getName()
Definition
Product.java:16
VendingMachine
Definition
VendingMachine.java:4
VendingMachine.getProduct
Product getProduct(String name)
Definition
VendingMachine.java:71
Command
Definition
Command.java:1
assignment3
CmdCheckProductInfo.java
Generated on Sat Dec 7 2024 17:10:09 for COMP2396 by
1.12.0