Skip to content
Snippets Groups Projects
Commit 41c839a0 authored by Ferreira Pires, Luis (UT-EEMCS)'s avatar Ferreira Pires, Luis (UT-EEMCS)
Browse files

Modified application to set the number of elements to be purchased (to make...

Modified application to set the number of elements to be purchased (to make service more interesting).
parent 70d06be0
Branches
No related tags found
No related merge requests found
......@@ -30,3 +30,5 @@ out/
### VS Code ###
.vscode/
.DS_Store
bin
1614157428833:current
1614157453899:exit
1614511411899:current
1614511421913:purchase
1614511428936:sell 50
1614511431942:current
1614511701060:purchase
1614511706073:purchase 20
1614511711082:sell
1614511716096:sell 200
1614511723110:current
1614511728131:sell 120
1614511733140:sell 20
1614511739156:current
1614511848909:purchase 10
1614511852915:current
1614511857930:sell 110
1614511874976:sell 105
1614511880024:current
......@@ -9,32 +9,26 @@ import org.springframework.shell.standard.ShellMethod;
@ShellComponent
public class InventoryCommands {
@Autowired private InventoryService inventoryService;
@Autowired
private InventoryService inventoryService;
@ShellMethod("Sell inventory")
public String sell(
int amount
) {
inventoryService.subtractInventory(amount);
return "Sold inventory";
}
@ShellMethod("Sell inventory")
public String sell(int amount) {
inventoryService.subtractInventory(amount);
return "Sold inventory";
}
@ShellMethod("Buy new inventory")
public String purchase() {
@ShellMethod("Buy new inventory")
public String purchase(int amount) {
// Do a request to the Purchase service
inventoryService.addInventory(50);
return "Jeej new inventory";
}
@ShellMethod("Get Current inventory")
public String current(){
return "Current inventory: " + inventoryService.getCurrentInventory();
}
// Request to the Purchase service should be done here!!!
inventoryService.addInventory(amount);
return "More " + amount + " items in the inventory";
}
@ShellMethod("Get Current inventory")
public String current() {
return "Current inventory: " + inventoryService.getCurrentInventory();
}
}
......@@ -12,8 +12,8 @@ public class InventoryService {
return InventoryService.currentInventory;
}
public void addInventory(int ammount){
InventoryService.currentInventory += currentInventory;
public void addInventory(int amount){
InventoryService.currentInventory += amount;
}
public void subtractInventory(int amount){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment