WSUniversalLib.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace TestSession2
  7. {
  8. public class Product
  9. {
  10. public int productType;
  11. public int materialType;
  12. public double count;
  13. public double lenght;
  14. public double width;
  15. public Product(int productType, int materialType, double count, double lenght, double width)
  16. {
  17. this.productType = productType;
  18. this.materialType = materialType;
  19. this.count = count;
  20. this.lenght = lenght;
  21. this.width = width;
  22. }
  23. }
  24. public static class WSUniversalLib
  25. {
  26. static List<double> productType = new List<double>() {1.1, 2.5, 8.43 };
  27. static List<double> materialType = new List<double>() { 0.3, 0.12 };
  28. public static double Calculate(Product product)
  29. {
  30. if (product.productType >=0 && product.productType <= 2 && product.materialType>=0 && product.materialType<=2 )
  31. {
  32. // exist
  33. double highQualityMaterial = product.lenght * product.width * productType[product.productType];
  34. double quanityOfHighQuality = product.count * highQualityMaterial;
  35. double withMarriage = (quanityOfHighQuality * (materialType[product.materialType]/100)) + quanityOfHighQuality;
  36. return Math.Ceiling(withMarriage);
  37. }
  38. return -1;
  39. }
  40. }
  41. }