123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- 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)
- {
- if (count <= -1)
- {
- throw new ArgumentException("Количество меньшу нуля");
- }
- if(width <= -1)
- {
- throw new ArgumentException("Ширина меньше нуля");
- }
- if (length <= -1)
- {
- throw new ArgumentException("Длина меньше нуля");
- }
- double sqaure = width * length;
- double quantity;
- switch(productType)
- {
- case 1:
- quantity = sqaure * 1.1;
- break;
- case 2:
- quantity = sqaure * 2.5;
- break;
- case 3:
- quantity = sqaure * 8.43;
- break;
- default:
- return -1;
- break;
- }
- quantity = quantity * count;
- switch(materialType)
- {
- case 1:
- quantity = quantity * 1.003;
- break;
- case 2:
- quantity = quantity * 1.0012;
- break;
- default:
- return -1;
- break;
- }
- return Convert.ToInt32(Math.Ceiling(quantity));
- }
- }
- }
|