Calculation.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace WSUniversalLib
  7. {
  8. public class Calculation
  9. {
  10. public static int GetQuantityForProduct(int productType, int materialType, int count, float width, float length)
  11. {
  12. if (count <= -1)
  13. {
  14. throw new ArgumentException("Количество меньшу нуля");
  15. }
  16. if(width <= -1)
  17. {
  18. throw new ArgumentException("Ширина меньше нуля");
  19. }
  20. if (length <= -1)
  21. {
  22. throw new ArgumentException("Длина меньше нуля");
  23. }
  24. double sqaure = width * length;
  25. double quantity;
  26. switch(productType)
  27. {
  28. case 1:
  29. quantity = sqaure * 1.1;
  30. break;
  31. case 2:
  32. quantity = sqaure * 2.5;
  33. break;
  34. case 3:
  35. quantity = sqaure * 8.43;
  36. break;
  37. default:
  38. return -1;
  39. break;
  40. }
  41. quantity = quantity * count;
  42. switch(materialType)
  43. {
  44. case 1:
  45. quantity = quantity * 1.003;
  46. break;
  47. case 2:
  48. quantity = quantity * 1.0012;
  49. break;
  50. default:
  51. return -1;
  52. break;
  53. }
  54. return Convert.ToInt32(Math.Ceiling(quantity));
  55. }
  56. }
  57. }