// CompareRandomNumbersToUserNumbers: Compares the current RandomNumbers to the list numbers given by the users input and hence // saved in LottoNumbers. // Pre: Both RandomNumbers and LottoNumbers contains 7 unique numbers. // Post: The number of matches between the two lists have been returned. private int CompareRandomNumbersToUserNumbers() { int numberOfMatches = 0; for (int i = 0; i < numberOfLottoNumbers; i++) { if (RandomNumbers.Contains(LottoNumbers[i])) { numberOfMatches++; } } return(numberOfMatches); }
private void GenerateRandomLottoNumbers() { RandomNumbers.Clear(); while (RandomNumbers.Count < numberOfLottoNumbers) { int nextNumber = Randomizer.Next(lowerBound, lottoNumberUpperBound + 1); while (RandomNumbers.Contains(nextNumber)) { nextNumber = Randomizer.Next(lowerBound, lottoNumberUpperBound + 1); } RandomNumbers.Add(nextNumber); } }