Calculation.cs 932 B

123456789101112131415161718192021222324252627282930313233
  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 GetQuantityForAgent(int agentType, int materialType, int count, float width, float length)
  11. {
  12. double[] matKoef = { 0, 0.1, 0.17, 0.26 };
  13. double[] prodKoef = { 0, 1.8, 3.2, 4.1 };
  14. if (agentType <= 0 || materialType <= 0 || count <= 0 || width <= 0 || length <= 0)
  15. {
  16. return -1;
  17. }
  18. try
  19. {
  20. int matCount = (int)Math.Ceiling(count * width * length * prodKoef[agentType] / matKoef[materialType]);
  21. return matCount;
  22. }
  23. catch
  24. {
  25. return -1;
  26. }
  27. }
  28. }
  29. }