/// <summary> /// Gets the multiplier for the third band color /// </summary> /// <param name="bandColor">The third band color used to calculate the multiplier.</param> public int GetMultiplierValue(string bandColor) { int result; //Match color with its corresponding BandColor BandColor multiplierBand = BandColors.Single(bc => bandColor.ToUpper().Equals(bc.Color)); result = multiplierBand.Multiplier; return(result); }
/// <summary> /// Gets the tolerance for the fourth band color /// </summary> /// <param name="bandColor">The fourth band color used to calculate the tolerance.</param> public double GetToleranceValue(string bandColor) { double result; //Match color with its corresponding BandColor BandColor toleranceBand = BandColors.Single(bc => bandColor.ToUpper().Equals(bc.Color)); result = toleranceBand.Tolerance; return(result); }
/// <summary> /// Calculates the Ohm value of a resistor based on the band colors. /// </summary> /// <param name="bandAColor">The color of the first figure of component value band.</param> /// <param name="bandBColor">The color of the second significant figure band.</param> /// <param name="bandCColor">The color of the decimal multiplier band.</param> /// <param name="bandDColor">The color of the tolerance value band.</param> public int CalculateOhmValue(string bandAColor, string bandBColor, string bandCColor, string bandDColor) { int result; //Match the colors with their corresponding BandColor BandColor bandA = BandColors.Single(bca => bandAColor.ToUpper().Equals(bca.Color)); BandColor bandB = BandColors.Single(bcb => bandBColor.ToUpper().Equals(bcb.Color)); //Combine first two SigFigures digits into one int result = Convert.ToInt32($"{bandA.SigFigures}{bandB.SigFigures}"); return(result); }