COMP2396
Loading...
Searching...
No Matches
CmdInsertCoin.java
Go to the documentation of this file.
1public class CmdInsertCoin implements Command {
2
3 @Override
4 public String execute(VendingMachine v, String[] cmdParts) {
5 Integer c = Integer.valueOf(cmdParts[1]);
6 // Add the coin to Coin Slot
7 v.insertCoin(c);
8 // Do something
9 // return a string "Inserted a $x coin. $y in total."
10 return "Inserted a $" + c + " coin. $" + v.getTotalInsertedCoinsAmount() + " in total.";
11 // x and y must be replaced by an appropriate value
12
13 }
14}
String execute(VendingMachine v, String[] cmdParts)
void insertCoin(Integer c)
int getTotalInsertedCoinsAmount()