/**
* This method should compare two Sets of Integers and return a new
* Set of Integers that represent all of the matching numbers.
*
* For example, if the lotteryNumbers are (4, 6, 23, 34, 44, 45) and
* the userNumbers are (4, 18, 22, 24, 35, 45) then the returned Set
* of Integers should be (4, 45)
*
* @param lotteryNumbers the lottery numbers that were randomly generated.
* @param userNumbers the user picked numbers that were picked in the console.
* @return Set of matched numbers
*/
public Set<Integer> playLottery (Set<Integer> lotteryNumbers, Set<Integer> userNumbers) {
Set<Integer> listOfRandom = new HashSet<Integer>(lotteryNumbers);
listOfRandom.equals(lotteryNumbers);
listOfRandom.addAll(lotteryNumbers);
Set<Integer> s = new HashSet<Integer>(userNumbers);
s.equals(userNumbers);
s.addAll(userNumbers);
Set<Integer> e = new HashSet<Integer>();
for (Integer integer : userNumbers) {
if (userNumbers.equals(lotteryNumbers));
userNumbers.remove(lotteryNumbers);
}
return userNumbers;
}
截至目前,它只返回所有用户编号。我假设 remove() 方法将删除返回的任何重复值。我需要这个来通过我的单元测试。