Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class Lottery {
- private final LotteryPrize prize; // custom object can be a coupon, can be merchant aparell, merchandise
- private int numberOfWinners;
- private List<Customer> participants;
- private Date endTime;
- private LotteryWinnerChooser chooser;
- private LotteryPrizeAwarder awarder;
- private LotteryAnnouncer announcer;
- public abstract void addParticipant(Customer participant);
- public abstract void announceSelf();
- public abstract void awardPrize();
- }
- public interface LotteryWinnerChooser {
- /**
- * Chooses a subset of the provided participants of the provided number
- * and returns them as the winners.
- */
- public List<Customer> getWinners(List<Customer> participants, int numberOfWinners);
- }
- public interface LotteryPrizeAwarder {
- /**
- * Provides a way to all winners to collect their prize.
- */
- public void award(LotteryPrize prize, List<Customer> winners);
- }
- public interface LotteryAnnouncer {
- /**
- * Announces the lottery to potential participants.
- */
- public void announce(Lottery lottery);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement