Review fixes

This commit is contained in:
Ilkka Seppälä 2016-05-21 21:48:25 +03:00
parent 49ca63087c
commit 75ed1b1a96
10 changed files with 70 additions and 11 deletions

View File

@ -32,11 +32,7 @@
<artifactId>java-design-patterns</artifactId>
<version>1.12.0-SNAPSHOT</version>
</parent>
<groupId>com.iluwatar.hexagonal</groupId>
<artifactId>hexagonal</artifactId>
<version>1.0-SNAPSHOT</version>
<name>hexagonal</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>

View File

@ -35,8 +35,19 @@ import com.iluwatar.hexagonal.domain.LotteryTicketId;
*/
public interface LotteryAdministration {
/**
* Get all the lottery tickets submitted for lottery
*/
Map<LotteryTicketId, LotteryTicket> getAllSubmittedTickets();
/**
* Draw lottery numbers
*/
LotteryNumbers performLottery();
/**
* Begin new lottery round
*/
void resetLottery();
}

View File

@ -47,13 +47,9 @@ import com.iluwatar.hexagonal.service.LotteryServiceImpl;
public class LotteryAdministrationImpl implements LotteryAdministration {
private final LotteryTicketRepository repository;
private final LotteryService service = new LotteryServiceImpl();
private final LotteryNotifications notifications = new LotteryNotificationsImpl();
private final WireTransfers bank = new WireTransfersImpl();
public LotteryAdministrationImpl() {
repository = new LotteryTicketInMemoryRepository();
}

View File

@ -29,8 +29,19 @@ package com.iluwatar.hexagonal.banking;
*/
public interface WireTransfers {
/**
* Set amount of funds for bank account
*/
void setFunds(String bankAccount, int amount);
/**
* Get amount of funds for bank account
*/
int getFunds(String bankAccount);
/**
* Transfer funds from one bank account to another
*/
boolean transferFunds(int amount, String sourceBackAccount, String destinationBankAccount);
}

View File

@ -35,9 +35,24 @@ import com.iluwatar.hexagonal.domain.LotteryTicketId;
*/
public interface LotteryTicketRepository {
/**
* Find lottery ticket by id
*/
Optional<LotteryTicket> findById(LotteryTicketId id);
/**
* Save lottery ticket
*/
Optional<LotteryTicketId> save(LotteryTicket ticket);
/**
* Get all lottery tickets
*/
Map<LotteryTicketId, LotteryTicket> findAll();
/**
* Delete all lottery tickets
*/
void deleteAll();
}

View File

@ -32,7 +32,6 @@ public class LotteryTicketCheckResult {
public enum CheckResult { WIN_PRIZE, NO_PRIZE, TICKET_NOT_SUBMITTED };
private final CheckResult checkResult;
private final int prizeAmount;
/**

View File

@ -24,6 +24,9 @@ package com.iluwatar.hexagonal.domain;
import java.util.UUID;
/**
* Lottery ticked id
*/
public class LotteryTicketId {
private final UUID id;

View File

@ -30,11 +30,30 @@ import com.iluwatar.hexagonal.domain.PlayerDetails;
*
*/
public interface LotteryNotifications {
/**
* Notify lottery ticket was submitted
*/
void notifyTicketSubmitted(PlayerDetails details);
/**
* Notify there was an error submitting lottery ticket
*/
void notifyTicketSubmitError(PlayerDetails details);
/**
* Notify lottery ticket did not win
*/
void notifyNoWin(PlayerDetails details);
/**
* Notify that prize has been paid
*/
void notifyPrize(PlayerDetails details, int prizeAmount);
/**
* Notify that there was an error paying the prize
*/
void notifyPrizeError(PlayerDetails details, int prizeAmount);
}

View File

@ -36,7 +36,13 @@ import com.iluwatar.hexagonal.domain.LotteryTicketId;
*/
public interface LotteryService {
/**
* Submit lottery ticket to participate in the lottery
*/
Optional<LotteryTicketId> submitTicket(LotteryTicket ticket);
/**
* Check if lottery ticket has won
*/
LotteryTicketCheckResult checkTicketForPrize(LotteryTicketId id, LotteryNumbers winningNumbers);
}

View File

@ -49,7 +49,10 @@ public class LotteryServiceImpl implements LotteryService {
private final WireTransfers bank = new WireTransfersImpl();
private final LotteryNotifications notifications = new LotteryNotificationsImpl();
/**
* Constructor
*/
public LotteryServiceImpl() {
repository = new LotteryTicketInMemoryRepository();
}