/// <summary> /// Calculates the Ohm value of a resistor based on the band colors. /// </summary> /// <param name="bandAColor">The color of the first significant figure of component value (left side).</param> /// <param name="bandBColor">The color of the second significant figure of component value.</param> /// <param name="bandCColor">The color of the decimal muliplier band (number of trailing zeroes).</param> /// <param name="bandDColor">The color of the tolerance value band in percent (no band means 20%).</param> /// <exception cref="InvalidOperationException"> /// 1. <paramref name="bandAColor"/> is null. OR /// 2. <paramref name="bandAColor"/>Is not "Black" AND either: /// <paramref name="bandBColor"/> is null OR /// <paramref name="bandCColor"/> is null /// </exception> /// <returns> /// A <see langword="Touple{double lower,double upper}"> representing the lower and upper bounds of the resistor's in Ohms /// </returns> public (double ohmValue, double tolerance) CalculateOhmValue( string bandAColor, string bandBColor, string bandCColor, string bandDColor) { var bandAData = GetBandDataByColor(bandAColor); var bandBData = GetBandDataByColor(bandBColor); var bandCData = GetBandDataByColor(bandCColor); var bandDData = GetBandDataByColor(bandDColor); var toleranceRanges = ICalculateOhmValues.CalculateOhmValue( bandAData, bandBData, bandCData, bandDData ); return(toleranceRanges); }
public ResistorController(ICalculateOhmValues calculateOhmValues, ILogger <ResistorController> logger) { _calculateOhmValues = calculateOhmValues; _logger = logger; }