-
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.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
12 changed files
with
350 additions
and
89 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
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
64 changes: 64 additions & 0 deletions
64
BerlinAIT/Cohort42.1project/JavaPizza/src/pizza/controller/CustomerController.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,64 @@ | ||
package pizza.controller; | ||
|
||
import pizza.service.CustomerService; | ||
|
||
import java.util.Scanner; | ||
|
||
/** | ||
* Pizza service controller | ||
* Implements a menu for working with customer service | ||
* | ||
* @author Sergey Iryupin | ||
* @version 18-Apr-24 | ||
*/ | ||
public class CustomerController { | ||
private CustomerService service; | ||
private Scanner scanner; | ||
|
||
public CustomerController(CustomerService customerService, Scanner scanner) { | ||
this.service = customerService; | ||
this.scanner = scanner; | ||
} | ||
|
||
public void run() { | ||
char cmd; | ||
String[] input; | ||
String name, address, phone; | ||
int id; | ||
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("Customer service: add: name & address & phone: "); | ||
input = scanner.nextLine().split("&"); | ||
name = input[0].trim(); | ||
address = input[1].trim(); | ||
phone = input[2].trim(); | ||
service.add(name, address, phone); | ||
break; | ||
case 'u': | ||
System.out.print("Customer service: update: id & name & composition & price: "); | ||
input = scanner.nextLine().split("&"); | ||
id = Integer.valueOf(input[0].trim()); | ||
name = input[1].trim(); | ||
address = input[2].trim(); | ||
phone = input[3].trim(); | ||
service.update(id, name, address, phone); | ||
break; | ||
case 'd': | ||
System.out.print("Customer service: delete: id: "); | ||
id = Integer.valueOf(scanner.nextLine()); | ||
service.delete(id); | ||
break; | ||
case 'p': | ||
service.print(); | ||
break; | ||
case 'b': | ||
break; | ||
default: | ||
System.out.println("Unrecognized command: " + cmd); | ||
} | ||
} while (cmd != 'b'); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
BerlinAIT/Cohort42.1project/JavaPizza/src/pizza/controller/ExtComponentController.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,62 @@ | ||
package pizza.controller; | ||
|
||
import pizza.service.ExtComponentService; | ||
|
||
import java.util.Scanner; | ||
|
||
/** | ||
* Pizza service controller | ||
* Implements a menu for working with ext component service | ||
* | ||
* @author Sergey Iryupin | ||
* @version 18-Apr-24 | ||
*/ | ||
public class ExtComponentController { | ||
private ExtComponentService service; | ||
private Scanner scanner; | ||
|
||
public ExtComponentController(ExtComponentService service, Scanner scanner) { | ||
this.service = service; | ||
this.scanner = scanner; | ||
} | ||
|
||
public void run() { | ||
char cmd; | ||
String[] input; | ||
String name; | ||
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("ExtComponent service: add: name & price: "); | ||
input = scanner.nextLine().split("&"); | ||
name = input[0].trim(); | ||
price = Integer.valueOf(input[1].trim()); | ||
service.add(name, price); | ||
break; | ||
case 'u': | ||
System.out.print("ExtComponent service: update: id & name & price: "); | ||
input = scanner.nextLine().split("&"); | ||
id = Integer.valueOf(input[0].trim()); | ||
name = input[1].trim(); | ||
price = Integer.valueOf(input[2].trim()); | ||
service.update(id, name, price); | ||
break; | ||
case 'd': | ||
System.out.print("ExtComponent service: delete: id: "); | ||
id = Integer.valueOf(scanner.nextLine()); | ||
service.delete(id); | ||
break; | ||
case 'p': | ||
service.print(); | ||
break; | ||
case 'b': | ||
break; | ||
default: | ||
System.out.println("Unrecognized command: " + cmd); | ||
} | ||
} while (cmd != 'b'); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
BerlinAIT/Cohort42.1project/JavaPizza/src/pizza/controller/OrderController.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,50 @@ | ||
package pizza.controller; | ||
|
||
import pizza.service.OrderService; | ||
|
||
import java.util.Scanner; | ||
|
||
/** | ||
* Pizza service controller | ||
* Implements a menu for working with order service | ||
* | ||
* @author Sergey Iryupin | ||
* @version 18-Apr-24 | ||
*/ | ||
public class OrderController { | ||
private OrderService service; | ||
private Scanner scanner; | ||
|
||
public OrderController(OrderService service, Scanner scanner) { | ||
this.service = service; | ||
this.scanner = scanner; | ||
} | ||
|
||
public void run() { | ||
char cmd; | ||
String[] input; | ||
int id; | ||
do { | ||
System.out.print("Order service: [c]reate, [d]elete, [e]dit, [p]rint, [b]ack: "); | ||
cmd = scanner.nextLine().charAt(0); | ||
switch (cmd) { | ||
case 'c': | ||
// TODO | ||
break; | ||
case 'd': | ||
// TODO | ||
break; | ||
case 'e': | ||
// TODO | ||
break; | ||
case 'p': | ||
// TODO | ||
break; | ||
case 'b': | ||
break; | ||
default: | ||
System.out.println("Unrecognized command: " + cmd); | ||
} | ||
} while (cmd != 'b'); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
BerlinAIT/Cohort42.1project/JavaPizza/src/pizza/controller/PizzaController.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,64 @@ | ||
package pizza.controller; | ||
|
||
import pizza.service.PizzaService; | ||
|
||
import java.util.Scanner; | ||
|
||
/** | ||
* Pizza service controller | ||
* Implements a menu for working with pizza service | ||
* | ||
* @author Sergey Iryupin | ||
* @version 18-Apr-24 | ||
*/ | ||
public class PizzaController { | ||
private PizzaService service; | ||
private Scanner scanner; | ||
|
||
public PizzaController(PizzaService pizzaService, Scanner scanner) { | ||
this.service = pizzaService; | ||
this.scanner = scanner; | ||
} | ||
|
||
public void run() { | ||
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()); | ||
service.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()); | ||
service.update(id, name, composition, price); | ||
break; | ||
case 'd': | ||
System.out.print("Pizza service: delete: id: "); | ||
id = Integer.valueOf(scanner.nextLine()); | ||
service.delete(id); | ||
break; | ||
case 'p': | ||
service.print(); | ||
break; | ||
case 'b': | ||
break; | ||
default: | ||
System.out.println("Unrecognized command: " + cmd); | ||
} | ||
} while (cmd != 'b'); | ||
} | ||
} |
Oops, something went wrong.