using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace WSUniversalLib { public class Calculation { public static int GetQuantityForProduct(int productType, int materialType, int count, float width, float length) { float materialCount = 0f; if (count < 0) { throw new ArgumentException("Количество < 0"); } if (width < 0) { throw new ArgumentException("Ширина < 0"); } if (width == null) { throw new ArgumentNullException("ширина = NULL"); } if (length < 0) { throw new ArgumentException("Длинна < 0"); } if (length == null) { throw new ArgumentNullException("длинна = NULL"); } switch (productType) { case 1: materialCount = width * length * count * 1.1f; break; case 2: materialCount = width * length * count * 2.5f; break; case 3: materialCount = width * length * count * 8.43f; break; default: return -1; } switch (materialType) { case 1: materialCount *= 1.003f; break; case 2: materialCount *= 1.0012f; break; default: return -1; } return (int)Math.Ceiling((decimal)materialCount); } } }