Skip to content

Commit 76eafab

Browse files
Context is given by paramter.
1 parent 2c02180 commit 76eafab

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

terminalCli/src/main/java/commands/AddProduct.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public AddProduct(Product prod)
1919
this.prod = prod;
2020
}
2121

22-
public void execute()
22+
public void execute(Screen context)
2323
{
2424
try {
25-
Screen.ordSer.addProductToOrder(Screen.activeCafeteria, Screen.activeOrder, prod, 1);
25+
context.ordSer.addProductToOrder(context.activeCafeteria, context.activeOrder, prod, 1);
2626
} catch (InsufficientStockException ex)
2727
{
2828
System.err.println(ex.toString());
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package commands;
22

3+
import terminalcli.Screen;
4+
35
/**
46
* @author Borja_FM
57
*/
68

79

810
public interface Command {
911

10-
public void execute();
12+
public void execute(Screen context);
1113
}

terminalCli/src/main/java/commands/RemoveProduct.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ public RemoveProduct(Product prod)
2020
this.prod = prod;
2121
}
2222

23-
public void execute()
23+
public void execute(Screen context)
2424
{
2525
try {
26-
Screen.ordSer.removeProductFromOrder(Screen.activeCafeteria, Screen.activeOrder, prod, 1);
26+
context.ordSer.removeProductFromOrder(context.activeCafeteria, context.activeOrder, prod, 1);
2727
} catch (InsufficientStockException ex)
2828
{
2929
System.err.println(ex.toString());

terminalCli/src/main/java/commands/ShowCafeteriaProducts.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
public class ShowCafeteriaProducts implements Command {
1212

13-
public void execute()
13+
public void execute(Screen context)
1414
{
1515

1616
}

terminalCli/src/main/java/commands/ShowProductTypes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public ShowProductTypes(UIElement menu, String type)
2121
productType = type;
2222
}
2323

24-
public void execute()
24+
public void execute(Screen context)
2525
{
26-
List<String> types = Screen.activeCafeteria.getTypes();
26+
List<String> types = context.activeCafeteria.getTypes();
2727

2828
for(String type : types)
2929
{

0 commit comments

Comments
 (0)