Advertisement
billt

Lottery Configuration

Aug 31st, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. public abstract class Lottery {
  2.    
  3.     private final LotteryPrize prize; // custom object can be a coupon, can be merchant aparell, merchandise
  4.    
  5.     private int numberOfWinners;
  6.     private List<Customer> participants;
  7.    
  8.     private Date endTime;
  9.    
  10.     private LotteryWinnerChooser chooser;
  11.     private LotteryPrizeAwarder awarder;
  12.     private LotteryAnnouncer announcer;
  13.    
  14.    
  15.     public abstract void addParticipant(Customer participant);
  16.     public abstract void announceSelf();
  17.     public abstract void awardPrize();
  18.    
  19. }
  20.  
  21. public interface LotteryWinnerChooser {
  22.    
  23.     /**
  24.      * Chooses a subset of the provided participants of the provided number
  25.      * and returns them as the winners.
  26.      */
  27.     public List<Customer> getWinners(List<Customer> participants, int numberOfWinners);
  28.    
  29. }
  30.  
  31. public interface LotteryPrizeAwarder {
  32.    
  33.     /**
  34.      * Provides a way to all winners to collect their prize.
  35.      */
  36.     public void award(LotteryPrize prize, List<Customer> winners);
  37.    
  38. }
  39.  
  40. public interface LotteryAnnouncer {
  41.    
  42.     /**
  43.      * Announces the lottery to potential participants.
  44.      */
  45.     public void announce(Lottery lottery);
  46.    
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement