-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
123 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
BerlinAIT/Cohort42.1project/JavaPizza/src/pizza/controller/AppController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package pizza.controller; | ||
|
||
import pizza.service.CustomerService; | ||
import pizza.service.ExtComponentService; | ||
import pizza.service.OrderService; | ||
import pizza.service.PizzaService; | ||
|
||
import java.util.Scanner; | ||
|
||
public class AppController { | ||
private PizzaService pizzaService; | ||
private ExtComponentService extСomponentService; | ||
private CustomerService customerService; | ||
private OrderService orderService; | ||
private Scanner scanner; | ||
|
||
public AppController(PizzaService pizzaService, | ||
ExtComponentService extСomponentService, | ||
CustomerService customerService, | ||
OrderService orderService) { | ||
this.pizzaService = pizzaService; | ||
this.extСomponentService = extСomponentService; | ||
this.customerService = customerService; | ||
this.orderService = orderService; | ||
this.scanner = new Scanner(System.in); | ||
} | ||
|
||
public void run() { | ||
char cmd; | ||
do { | ||
System.out.print("Choose service: [p]izza, [e]xtcomponent, [c]ustomer, [o]rder, e[x]it: "); | ||
cmd = scanner.nextLine().charAt(0); | ||
switch (cmd) { | ||
case 'p': | ||
pizzaServiceMenu(); | ||
break; | ||
case 'e': | ||
// TODO Call ExtComponentService | ||
break; | ||
case 'c': | ||
// TODO Call CustomerService | ||
break; | ||
case 'o': | ||
// TODO Call OrderService | ||
break; | ||
case 'x': | ||
break; | ||
default: | ||
System.out.println("Unrecognized command: " + cmd); | ||
} | ||
} while (cmd != 'x'); | ||
System.out.println("Exit."); | ||
} | ||
|
||
private void pizzaServiceMenu() { | ||
char cmd; | ||
String[] input; | ||
String name, composition; | ||
int id, price; | ||
do { | ||
System.out.print("Pizza service: [a]dd, [u]pdate, [d]elete, [p]rint, [b]ack: "); | ||
cmd = scanner.nextLine().charAt(0); | ||
switch (cmd) { | ||
case 'a': | ||
System.out.print("Pizza service: add: name & composition & price: "); | ||
input = scanner.nextLine().split("&"); | ||
name = input[0].trim(); | ||
composition = input[1].trim(); | ||
price = Integer.valueOf(input[2].trim()); | ||
pizzaService.add(name, composition, price); | ||
break; | ||
case 'u': | ||
System.out.print("Pizza service: update: id & name & composition & price: "); | ||
input = scanner.nextLine().split("&"); | ||
id = Integer.valueOf(input[0].trim()); | ||
name = input[1].trim(); | ||
composition = input[2].trim(); | ||
price = Integer.valueOf(input[3].trim()); | ||
pizzaService.update(id, name, composition, price); | ||
break; | ||
case 'd': | ||
System.out.print("Pizza service: delete: id: "); | ||
id = Integer.valueOf(scanner.nextLine()); | ||
pizzaService.delete(id); | ||
break; | ||
case 'p': | ||
pizzaService.print(); | ||
break; | ||
case 'b': | ||
break; | ||
default: | ||
System.out.println("Unrecognized command: " + cmd); | ||
} | ||
} while (cmd != 'b'); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ct/JavaPizza/src/pizza/base/Customer.java → ...ct/JavaPizza/src/pizza/data/Customer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package pizza.base; | ||
package pizza.data; | ||
|
||
/** | ||
* Pizza customer class | ||
|
2 changes: 1 addition & 1 deletion
2
...avaPizza/src/pizza/base/ExtСomponent.java → ...avaPizza/src/pizza/data/ExtСomponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package pizza.base; | ||
package pizza.data; | ||
|
||
/** | ||
* Extra (additional) component to standard pizza | ||
|
2 changes: 1 addition & 1 deletion
2
...oject/JavaPizza/src/pizza/base/Order.java → ...oject/JavaPizza/src/pizza/data/Order.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package pizza.base; | ||
package pizza.data; | ||
|
||
/** | ||
* Pizza order class | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../JavaPizza/src/pizza/base/OrderState.java → .../JavaPizza/src/pizza/data/OrderState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package pizza.base; | ||
package pizza.data; | ||
|
||
/** | ||
* Order states | ||
|
2 changes: 1 addition & 1 deletion
2
...oject/JavaPizza/src/pizza/base/Pizza.java → ...oject/JavaPizza/src/pizza/data/Pizza.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package pizza.base; | ||
package pizza.data; | ||
|
||
/** | ||
* Standard pizza class | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.