@Test(timeout = 10) public void oneEmail() throws InterruptedException { LotteryMachine machine = new LotteryMachine(2); List<String> result = machine.draw(Collections.singletonList("test")); Assert.assertEquals(1, result.size()); }
List<String> draw(List<String> emails) { System.out.println("Draw for the seed: " + getSeed()); Random rnd = new Random(getSeed()); Set<String> winners = new HashSet<>(); while (winners.size() < Math.min(winnersCount, emails.size())) { int index = rnd.nextInt(emails.size()); System.out.println("Ball: " + index); winners.add(emails.get(index)); } return new ArrayList<>(winners); }
LotteryMachine { List<String> draw(List<String> emails) { System.out.println("Draw for the seed: " + getSeed()); Random rnd = new Random(getSeed()); Set<String> winners = new HashSet<>(); while (winners.size() < Math.min(winnersCount, emails.size())) { int index = rnd.nextInt(emails.size()); System.out.println("Ball: " + index); winners.add(emails.get(index)); } return new ArrayList<>(winners); } }
LotteryMachine { List<String> draw(List<String> emails) { System.out.println("Draw for the seed: " + getSeed()); Random rnd = new Random(getSeed()); Set<String> winners = new HashSet<>(); while (winners.size() < Math.min(winnersCount, emails.size())) { int index = rnd.nextInt(emails.size()); System.out.println("Ball: " + index); winners.add(emails.get(index)); } return new ArrayList<>(winners); } LotteryMachine(int winnersCount); }
LotteryMachine { List<String> draw(List<String> emails) { System.out.println("Draw for the seed: " + getSeed()); Random rnd = new Random(getSeed()); Set<String> winners = new HashSet<>(); while (winners.size() < Math.min(winnersCount, emails.size())) { int index = rnd.nextInt(emails.size()); System.out.println("Ball: " + index); winners.add(emails.get(index)); } return new ArrayList<>(winners); } LotteryMachine(int winnersCount);  }
LotteryMachine { List<String> draw(List<String> emails) { System.out.println("Draw for the seed: " + getSeed()); Random rnd = new Random(getSeed()); Set<String> winners = new HashSet<>(); while (winners.size() < Math.min(winnersCount, emails.size())) { int index = rnd.nextInt(emails.size()); System.out.println("Ball: " + index); winners.add(emails.get(index)); } return new ArrayList<>(winners); } LotteryMachine(int winnersCount);   }