public TrifectaSubsystem(TrifectaSubsystem other) : this() { this._payoff = other._payoff; this._amountToDutch = other._amountToDutch; foreach(KeyValuePair<Position, List<int>> pair in other._selection) { Position otherPosition = pair.Key; List<int> otherList = pair.Value; List<int> thisList = _selection[otherPosition]; thisList.Clear(); foreach (int i in otherList) { thisList.Add(i); } } }
private bool IsPositionContained(Position pos, TrifectaSubsystem other) { List<int> thisList = _selection[pos]; List<int> otherList = other._selection[pos]; foreach (int i in otherList) { if (false == thisList.Contains(i)) { return false; } } return true; }
private bool ArePositionsIdentical(Position pos, TrifectaSubsystem other) { List<int> list1 = this._selection[pos]; List<int> list2 = other._selection[pos]; if (list1.Count != list2.Count) { return false; } foreach (int i in list1) { if (false == list2.Contains(i)) { return false; } } return true; }
public void Merge(TrifectaSubsystem other) { for (Position p = Position.First; p <= Position.Third; ++p) { foreach (int n in other._selection[p]) { AddHorseToSpecificPosition(p, n); } } }
public bool IsASuperset(TrifectaSubsystem other) { for (Position p = Position.First; p <= Position.Third; ++p) { if (!IsPositionContained(p, other)) { return false; } } return true; }
public int CountUnmatchedRaces(TrifectaSubsystem other) { int countDescrepancies = 0; for (Position p = Position.First; p <= Position.Third; ++p ) { if (!ArePositionsIdentical(p, other)) { ++countDescrepancies; } } return countDescrepancies; }