use of com.iluwatar.hexagonal.module.LotteryModule in project java-design-patterns by iluwatar.
the class ConsoleAdministration method main.
/**
* Program entry point
*/
public static void main(String[] args) {
MongoConnectionPropertiesLoader.load();
Injector injector = Guice.createInjector(new LotteryModule());
LotteryAdministration administartion = injector.getInstance(LotteryAdministration.class);
LotteryService service = injector.getInstance(LotteryService.class);
SampleData.submitTickets(service, 20);
try (Scanner scanner = new Scanner(System.in)) {
boolean exit = false;
while (!exit) {
printMainMenu();
String cmd = readString(scanner);
if ("1".equals(cmd)) {
administartion.getAllSubmittedTickets().forEach((k, v) -> LOGGER.info("Key: {}, Value: {}", k, v));
} else if ("2".equals(cmd)) {
LotteryNumbers numbers = administartion.performLottery();
LOGGER.info("The winning numbers: {}", numbers.getNumbersAsString());
LOGGER.info("Time to reset the database for next round, eh?");
} else if ("3".equals(cmd)) {
administartion.resetLottery();
LOGGER.info("The lottery ticket database was cleared.");
} else if ("4".equals(cmd)) {
exit = true;
} else {
LOGGER.info("Unknown command: {}", cmd);
}
}
}
}
use of com.iluwatar.hexagonal.module.LotteryModule in project java-design-patterns by iluwatar.
the class ConsoleLottery method main.
/**
* Program entry point
*/
public static void main(String[] args) {
MongoConnectionPropertiesLoader.load();
Injector injector = Guice.createInjector(new LotteryModule());
LotteryService service = injector.getInstance(LotteryService.class);
WireTransfers bank = injector.getInstance(WireTransfers.class);
try (final Scanner scanner = new Scanner(System.in)) {
boolean exit = false;
while (!exit) {
printMainMenu();
String cmd = readString(scanner);
if ("1".equals(cmd)) {
queryLotteryAccountFunds(bank, scanner);
} else if ("2".equals(cmd)) {
addFundsToLotteryAccount(bank, scanner);
} else if ("3".equals(cmd)) {
submitTicket(service, scanner);
} else if ("4".equals(cmd)) {
checkTicket(service, scanner);
} else if ("5".equals(cmd)) {
exit = true;
} else {
LOGGER.info("Unknown command");
}
}
}
}
Aggregations