12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace TestSession2
- {
- public class Product
- {
- public int productType;
- public int materialType;
- public double count;
- public double lenght;
- public double width;
- public Product(int productType, int materialType, double count, double lenght, double width)
- {
- this.productType = productType;
- this.materialType = materialType;
- this.count = count;
- this.lenght = lenght;
- this.width = width;
- }
- }
- public static class WSUniversalLib
- {
- static List<double> productType = new List<double>() {1.1, 2.5, 8.43 };
- static List<double> materialType = new List<double>() { 0.3, 0.12 };
- public static double Calculate(Product product)
- {
- if (product.productType >=0 && product.productType <= 2 && product.materialType>=0 && product.materialType<=2 )
- {
- // exist
- double highQualityMaterial = product.lenght * product.width * productType[product.productType];
- double quanityOfHighQuality = product.count * highQualityMaterial;
- double withMarriage = (quanityOfHighQuality * (materialType[product.materialType]/100)) + quanityOfHighQuality;
- return Math.Ceiling(withMarriage);
- }
- return -1;
- }
- }
- }
|