@Ignore("todo: 13131") @Test(timeout = 100) public void fiveEmails() { List<String> result = lotteryMachine .draw(Arrays.asList("0", "1", "2", "3", "4")); assertEquals(5, result.size()); Assert.assertTrue(result.contains("0")); Assert.assertTrue(result.contains("1")); Assert.assertTrue(result.contains("2")); Assert.assertTrue(result.contains("3")); Assert.assertTrue(result.contains("4")); }
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);   }