/// <summary> /// Counting the execution time of the algorithm for calculating the GCD /// </summary> /// <param name="a">First number</param> /// <param name="b">Second number</param> /// <param name="timeOfCalculation">Time of calculation</param> /// <param name="alghoritm">GCD calculation algorithm</param> /// <returns></returns> public int CalculateGcd(int a, int b, ref TimeSpan timeOfCalculation, IGcdCalculating alghoritm) { if (alghoritm is null) { throw new ArgumentNullException(nameof(alghoritm)); } Stopwatch time = new Stopwatch(); time.Start(); int gcd = alghoritm.CalculateGcd(a, b); time.Stop(); timeOfCalculation = time.Elapsed; return(gcd); }
/// <summary> /// Transmission of the GCD calculation algorithm /// </summary> /// <param name="alghoritm">GCD calculation algorithm</param> public GcdAlgorithmMultipleNumbers(IGcdCalculating alghoritm) { Alghoritm = alghoritm ?? throw new ArgumentNullException(nameof(alghoritm)); }