Review fixes
This commit is contained in:
parent
49ca63087c
commit
75ed1b1a96
@ -32,11 +32,7 @@
|
|||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0-SNAPSHOT</version>
|
<version>1.12.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>com.iluwatar.hexagonal</groupId>
|
|
||||||
<artifactId>hexagonal</artifactId>
|
<artifactId>hexagonal</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<name>hexagonal</name>
|
|
||||||
<url>http://maven.apache.org</url>
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
@ -35,8 +35,19 @@ import com.iluwatar.hexagonal.domain.LotteryTicketId;
|
|||||||
*/
|
*/
|
||||||
public interface LotteryAdministration {
|
public interface LotteryAdministration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the lottery tickets submitted for lottery
|
||||||
|
*/
|
||||||
Map<LotteryTicketId, LotteryTicket> getAllSubmittedTickets();
|
Map<LotteryTicketId, LotteryTicket> getAllSubmittedTickets();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw lottery numbers
|
||||||
|
*/
|
||||||
LotteryNumbers performLottery();
|
LotteryNumbers performLottery();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Begin new lottery round
|
||||||
|
*/
|
||||||
void resetLottery();
|
void resetLottery();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,13 +47,9 @@ import com.iluwatar.hexagonal.service.LotteryServiceImpl;
|
|||||||
public class LotteryAdministrationImpl implements LotteryAdministration {
|
public class LotteryAdministrationImpl implements LotteryAdministration {
|
||||||
|
|
||||||
private final LotteryTicketRepository repository;
|
private final LotteryTicketRepository repository;
|
||||||
|
|
||||||
private final LotteryService service = new LotteryServiceImpl();
|
private final LotteryService service = new LotteryServiceImpl();
|
||||||
|
|
||||||
private final LotteryNotifications notifications = new LotteryNotificationsImpl();
|
private final LotteryNotifications notifications = new LotteryNotificationsImpl();
|
||||||
|
|
||||||
private final WireTransfers bank = new WireTransfersImpl();
|
private final WireTransfers bank = new WireTransfersImpl();
|
||||||
|
|
||||||
public LotteryAdministrationImpl() {
|
public LotteryAdministrationImpl() {
|
||||||
repository = new LotteryTicketInMemoryRepository();
|
repository = new LotteryTicketInMemoryRepository();
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,19 @@ package com.iluwatar.hexagonal.banking;
|
|||||||
*/
|
*/
|
||||||
public interface WireTransfers {
|
public interface WireTransfers {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set amount of funds for bank account
|
||||||
|
*/
|
||||||
void setFunds(String bankAccount, int amount);
|
void setFunds(String bankAccount, int amount);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get amount of funds for bank account
|
||||||
|
*/
|
||||||
int getFunds(String bankAccount);
|
int getFunds(String bankAccount);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transfer funds from one bank account to another
|
||||||
|
*/
|
||||||
boolean transferFunds(int amount, String sourceBackAccount, String destinationBankAccount);
|
boolean transferFunds(int amount, String sourceBackAccount, String destinationBankAccount);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,9 +35,24 @@ import com.iluwatar.hexagonal.domain.LotteryTicketId;
|
|||||||
*/
|
*/
|
||||||
public interface LotteryTicketRepository {
|
public interface LotteryTicketRepository {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find lottery ticket by id
|
||||||
|
*/
|
||||||
Optional<LotteryTicket> findById(LotteryTicketId id);
|
Optional<LotteryTicket> findById(LotteryTicketId id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save lottery ticket
|
||||||
|
*/
|
||||||
Optional<LotteryTicketId> save(LotteryTicket ticket);
|
Optional<LotteryTicketId> save(LotteryTicket ticket);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all lottery tickets
|
||||||
|
*/
|
||||||
Map<LotteryTicketId, LotteryTicket> findAll();
|
Map<LotteryTicketId, LotteryTicket> findAll();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all lottery tickets
|
||||||
|
*/
|
||||||
void deleteAll();
|
void deleteAll();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,6 @@ public class LotteryTicketCheckResult {
|
|||||||
public enum CheckResult { WIN_PRIZE, NO_PRIZE, TICKET_NOT_SUBMITTED };
|
public enum CheckResult { WIN_PRIZE, NO_PRIZE, TICKET_NOT_SUBMITTED };
|
||||||
|
|
||||||
private final CheckResult checkResult;
|
private final CheckResult checkResult;
|
||||||
|
|
||||||
private final int prizeAmount;
|
private final int prizeAmount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,6 +24,9 @@ package com.iluwatar.hexagonal.domain;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lottery ticked id
|
||||||
|
*/
|
||||||
public class LotteryTicketId {
|
public class LotteryTicketId {
|
||||||
|
|
||||||
private final UUID id;
|
private final UUID id;
|
||||||
|
@ -31,10 +31,29 @@ import com.iluwatar.hexagonal.domain.PlayerDetails;
|
|||||||
*/
|
*/
|
||||||
public interface LotteryNotifications {
|
public interface LotteryNotifications {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify lottery ticket was submitted
|
||||||
|
*/
|
||||||
void notifyTicketSubmitted(PlayerDetails details);
|
void notifyTicketSubmitted(PlayerDetails details);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify there was an error submitting lottery ticket
|
||||||
|
*/
|
||||||
void notifyTicketSubmitError(PlayerDetails details);
|
void notifyTicketSubmitError(PlayerDetails details);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify lottery ticket did not win
|
||||||
|
*/
|
||||||
void notifyNoWin(PlayerDetails details);
|
void notifyNoWin(PlayerDetails details);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify that prize has been paid
|
||||||
|
*/
|
||||||
void notifyPrize(PlayerDetails details, int prizeAmount);
|
void notifyPrize(PlayerDetails details, int prizeAmount);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify that there was an error paying the prize
|
||||||
|
*/
|
||||||
void notifyPrizeError(PlayerDetails details, int prizeAmount);
|
void notifyPrizeError(PlayerDetails details, int prizeAmount);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,13 @@ import com.iluwatar.hexagonal.domain.LotteryTicketId;
|
|||||||
*/
|
*/
|
||||||
public interface LotteryService {
|
public interface LotteryService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Submit lottery ticket to participate in the lottery
|
||||||
|
*/
|
||||||
Optional<LotteryTicketId> submitTicket(LotteryTicket ticket);
|
Optional<LotteryTicketId> submitTicket(LotteryTicket ticket);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if lottery ticket has won
|
||||||
|
*/
|
||||||
LotteryTicketCheckResult checkTicketForPrize(LotteryTicketId id, LotteryNumbers winningNumbers);
|
LotteryTicketCheckResult checkTicketForPrize(LotteryTicketId id, LotteryNumbers winningNumbers);
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,9 @@ public class LotteryServiceImpl implements LotteryService {
|
|||||||
|
|
||||||
private final LotteryNotifications notifications = new LotteryNotificationsImpl();
|
private final LotteryNotifications notifications = new LotteryNotificationsImpl();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
public LotteryServiceImpl() {
|
public LotteryServiceImpl() {
|
||||||
repository = new LotteryTicketInMemoryRepository();
|
repository = new LotteryTicketInMemoryRepository();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user