//Public methods public bool PingTrig(uint PingNum) { uint FirstStatus = First.GetStatus(); uint SecondStatus = Second.GetStatus(); SetPings(GetPingAttempts() + 1); if (FirstStatus == 1) { First.Revive(); } if (SecondStatus == 1) { Second.Revive(); } uint remainder1 = First.Ping(PingNum) % 10; uint remainder2 = Second.Ping(PingNum) % 10; if (remainder1 == remainder2) { Console.WriteLine("Ping of " + PingNum + " resulted in last digit of " + remainder1); } bool MatchingDigits = (First.Ping(PingNum) % 10 == Second.Ping(PingNum) % 10); if (MatchingDigits) { SetMatches(GetMatches() + 1); } return(MatchingDigits); }
//Preconditions: For a non-zero output the queue must have at least 1 closeprime //object on it. Pinging a value of 0 is fine because the closePrime class will update it to 5. //Postconditions: It will update the data members. public uint[] Ping(uint PingNum) { uint[] values = new uint[2]; uint value; if (Initallized && CurSize > 0) { SetTotal(GetTotal() + 1); //I created a list to determine the minimum and maximum return values of this ping along //with updating the overall maximum, cumulative and minimum pinged values. List <uint> Returnvalues = new List <uint>((int)CurSize); for (int i = 0; i < CurSize; i++) { ClosePrime x = queue.Dequeue(); if (x.GetStatus() == 1) { x.Revive(); } value = x.Ping(PingNum); if (value > GetMaxPinged()) { SetMaxPinged(value); } if (value < GetMinPinged()) { SetMinPinged(value); } SetTotal(GetTotal() + value); //Since it's a queue (FIFO) dequeing everything and enqueuing works well. queue.Enqueue(x); Returnvalues.Add(value); } values[0] = Returnvalues.Min(); values[1] = Returnvalues.Max(); } return(values); }