public void Should_give_correct_modes_when_there_are_many()
 {
     var colours = new List<Colour> { _black, _white };
     var calculate = new Calculate(colours);
     Assert.That(calculate.ModeCount(), Is.EqualTo(1));
     Assert.That(calculate.ModeColour(), Is.EqualTo(new List<Colour>{_black,_white}));
 }
 public void Should_give_correct_mode_when_there_is_one()
 {
     var colours = new List<Colour> { _black, _black, _white };
     var calculate = new Calculate(colours);
     Assert.That(calculate.ModeCount(), Is.EqualTo(2));
     Assert.That(calculate.ModeColour().Single(), Is.EqualTo(_black));
 }
Beispiel #3
0
 public static void Main()
 {
     Calculate Square=new Calculate();
       Square.Area(2.3,3.5);
      Square.Long(2.3,3.5);
      Console.WriteLine("该长方形面积为:"+Square.Area(2.3,3.5)+"该长方形长度:"+Square.Long(2.3,3.5));
 }
 protected void btnCalculate_Click(object sender, EventArgs e)
 {
     Double a = 0, b = 0;
     Calculate calculate = new Calculate();
     if (Double.TryParse(txtNumber1.Text, out a)) {
         if (Double.TryParse(txtNumber2.Text, out b)) {
             a = System.Convert.ToDouble(txtNumber1.Text);
             b = System.Convert.ToDouble(txtNumber2.Text);
             if (rblSigns.SelectedItem.Value == "add")
             {
                 lblSign.Text = "+";
                 lblAnswer.Text = calculate.add(a, b).ToString();
             }
             else if (rblSigns.SelectedItem.Value == "subtract")
             {
                 lblSign.Text = "-";
                 lblAnswer.Text = calculate.subtract(a, b).ToString();
             }
             else if (rblSigns.SelectedItem.Value == "divide")
             {
                 lblSign.Text = "/";
                 lblAnswer.Text = calculate.divide(a, b).ToString();
             }
             else if (rblSigns.SelectedItem.Value == "multiply")
             {
                 lblSign.Text = "*";
                 lblAnswer.Text = calculate.multiply(a, b).ToString();
             }
         } else {
             lblAnswer.Text = "You need to use only Numbers";
         }
     } else {
         lblAnswer.Text = "You need to use only Numbers";
     }
 }
        public Program()
        {
            //Set the UI to the specified culture.
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(_culturename);

            //Create the XslTransform and load the stylesheet.
            //XslTransform xslt = new XslTransform();
            XslCompiledTransform xslt = new XslCompiledTransform();
            xslt.Load(_stylesheet);

            //Load the XML data file.
            XPathDocument doc = new XPathDocument(_filename);

            //Create an XsltArgumentList.
            XsltArgumentList xslArg = new XsltArgumentList();

            //Add an object to get the resources for the specified language.
            ResourceTranslator resTran = new ResourceTranslator("Resources.Resource");
            xslArg.AddExtensionObject("urn:myResTran", resTran);

            //Add an object to calculate the circumference of the circle.
            Calculate obj = new Calculate();
            xslArg.AddExtensionObject("urn:myObj", obj);

            //Create an XmlTextWriter to output to the console.
            XmlTextWriter writer = new XmlTextWriter(Console.Out);

            //Transform the file.
            xslt.Transform(doc, xslArg, writer, null);

            writer.Close();
        }
Beispiel #6
0
 public void ExecuteTest()
 {
     Calculate calculate = new Calculate();
     Assert.AreEqual(3, calculate.Execute("+", 1, 2));
     Assert.AreEqual(4, calculate.Execute("-", 10, 6));
     Assert.AreEqual(2, calculate.Execute("*", 1, 2));
     Assert.AreEqual(2, calculate.Execute("/", 4, 2));
 }
Beispiel #7
0
 static void Main()
 {
     Calculate calc = new Calculate();
     Console.WriteLine("Result = {0}.",
         calc.Result(234).ToString());
     Console.WriteLine("Result = {0}.",
         calc.Result(55).ToString());
 }
Beispiel #8
0
 public Calculator()
 {
     // Initialize the cal variable.
     cal = new Calculate(Add);
     // There're also another ways to initialize
     // a Calculate type variable by:
     // can = Add
     cal += Subtract;
 }
        static void Main(string[] args)
        {
            myUtil myUtilObject = new myUtil();

            Calculate calculateFunction = new Calculate(myUtilObject.addMethod);

            calculateFunction = calculateFunction + new Calculate(myUtilObject.divideMethod);
            calculateFunction = calculateFunction + new Calculate(myUtilObject.multiplyMethod);
        }
 private void DrawExaggeratedMeans(Calculate calculate, int yOffset)
 {
     for (int i = 0; i < _iterations; i++)
     {
         var colour = calculate.ExaggeratedMean(i);
         var xOffset = TextWidth + (i*SquareSize);
         DrawSquare(colour, xOffset, yOffset);
         WriteColourInfo(colour, xOffset, yOffset);
     }
 }
Beispiel #11
0
 public Noise(float s, float p, float o, Calculate c, Generator g) {
     scale = s; power = p; offset = o; calc = c;
     if (g == Generator.Vonoroi)
         vonoroi = Generators.Vonoroi(0.1, offset);
     else if (g == Generator.Perlin)
         perlin = Generators.Perlin(0.1, offset);
     else if (g == Generator.Billow)
         billow = Generators.Billow(0.1, offset);
     generator = g;
 }
Beispiel #12
0
    void Start()
    {
        GameObject g = GameObject.Find("Calculate");
        cal = g.GetComponent<Calculate> ();

        value = new double[cal.X, cal.Y];
        for (int i=0; i<160; i++) {
            for (int j=0; j<120; j++) {
                value [i, j] = -1;
            }
        }
        StartCoroutine (countTime(1.0f) );
    }
Beispiel #13
0
        static void Main(string[] args)
        {
            //creating the class which contains the methods
            //that will be assigned to delegate objects
            Program mc = new Program();

            //creating delegate objects and assigning appropriate methods //having the EXACT signature of the delegate
            Calculate add = new Calculate(mc.add);
            Calculate sub = new Calculate(mc.sub);
            //using the delegate objects to call the assigned methods
            Console.WriteLine("Adding two values: " + add(10, 6));
            Console.WriteLine("Subtracting two values: " + sub(10, 4));
            Console.ReadKey();
        }
Beispiel #14
0
 static void Main(string[] args)
 {
     int firstGrade = 0,  // first grade
         secondGrade = 0 ,// second grade
         thirdGrade = 0 , // third grade
         fourthGrade = 0 , // fourth grade
         fithGrade = 0 ;  // fith grade
     
     Intro(); // calling the intro method
     // instatiating a object
     Calculate grades = new Calculate( firstGrade, secondGrade, thirdGrade, fourthGrade, fithGrade);
     // input the grades
     grades.setGrade();
     //out put with a ToString
     Console.WriteLine(grades);
     Console.ReadLine();
 }
 public void Should_give_correct_exaggerated_means()
 {
     for (int i = 0; i < 256; i++)
     {
         var colour = new Colour(i, i, i);
         var calculate = new Calculate(new List<Colour> { colour });
         var exaggeratedMean = calculate.ExaggeratedMean(1);
         Assert.That(exaggeratedMean.Redness, Is.EqualTo(exaggeratedMean.Blueness));
         Assert.That(exaggeratedMean.Redness, Is.EqualTo(exaggeratedMean.Greenness));
         Assert.That(exaggeratedMean.Redness, Is.AtLeast(0));
         Assert.That(exaggeratedMean.Redness, Is.AtMost(255));
         if(i <= 126)
             Assert.That(exaggeratedMean.Redness, Is.LessThan(126));
         if(i >= 129)
             Assert.That(exaggeratedMean.Redness, Is.GreaterThan(129));
     }
 }
Beispiel #16
0
        public void preChange_preTreatment_IntegrationTest()
        {
            bool k = true;
            int  i = 0, n = polishRecord.Count();
            //
            var proc = new Calculate("cos(ctg(3.14/2))");

            polishRecord.Add("3.14");
            polishRecord.Add("2");
            polishRecord.Add("x");
            polishRecord.Add("w");
            while (i < n)
            {
                k  = polishRecord.ElementAt(i) == proc.polishRecord.ElementAt(i);
                i += 1;
            }
            Assert.IsTrue(k);
            proc = null;

            //proc = new Calculate("");
        }
Beispiel #17
0
        private void combo_samplerate_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (combo_samplerate.IsDropDownOpen || combo_samplerate.IsSelectionBoxHighlighted)
            {
                AudioStream instream  = (AudioStream)m.inaudiostreams[m.inaudiostream];
                AudioStream outstream = (AudioStream)m.outaudiostreams[m.outaudiostream];
                outstream.samplerate = Calculate.GetSplittedString(combo_samplerate.SelectedItem.ToString(), 0);

                AviSynthScripting.SamplerateModifers oldс = m.sampleratemodifer;
                m = Format.GetValidSamplerateModifer(m);
                if (oldс != m.sampleratemodifer)
                {
                    Message message = new Message(this);
                    message.ShowMessage(Languages.Translate("SSRC can`t convert") + ": " + instream.samplerate + " > " + outstream.samplerate + "!",
                                        Languages.Translate("Warning"), Message.MessageStyle.Ok);
                    combo_converter.SelectedValue = m.sampleratemodifer;
                }

                SetInfo();
            }
        }
Beispiel #18
0
        private BudgetStatus GetBudgetStatus(decimal amount, decimal maxAllowed)
        {
            var percentage = Calculate.Percentage(amount, maxAllowed);

            if (percentage == 0)
            {
                return(BudgetStatus.Empty);
            }
            else if (percentage < 50)
            {
                return(BudgetStatus.Low);
            }
            else if (percentage < 100)
            {
                return(BudgetStatus.High);
            }
            else
            {
                return(BudgetStatus.Overflowed);
            }
        }
Beispiel #19
0
        private void combo_sourcetype_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            if ((combo_sourcetype.IsDropDownOpen || combo_sourcetype.IsSelectionBoxHighlighted) && combo_sourcetype.SelectedItem != null)
            {
                m.interlace = GetEnumFromSTypeString(combo_sourcetype.SelectedItem.ToString());

                m = Format.GetOutInterlace(m);
                m = Calculate.UpdateOutFramerate(m);

                //обновляем форму
                combo_deinterlace.SelectedValue = m.deinterlace;
                combo_outinterlace.SelectedItem = Format.GetCodecOutInterlace(m);
                SetFramerateCombo(m.outframerate);

                //обновляем конечное колличество фреймов, с учётом режима деинтерелейса
                m             = Calculate.UpdateOutFrames(m);
                m.outfilesize = Calculate.GetEncodingSize(m);

                Refresh();
            }
        }
Beispiel #20
0
        public static void Main(string[] args)
        {
            // DemoDelegate.ShowMsg("xin chao cac ban");
            // DemoDelegate dd = new DemoDelegate();
            // dd.ShowInfo("xin chao cac ban");
            // ShowString ss = new ShowString(DemoDelegate.ShowMsg);// truyen vao ten cua ham
            DemoDelegate dd = new DemoDelegate(); // nap them vao vao danh sach thuc hien

            ss += DemoDelegate.ShowMsg;
            ss += DemoDelegate.ShowMsg;
            ss("xin chao cac ban");// chay delegate
            Calculate c = new Calculate(Calcutation.Add);

            c += Calcutation.Sub;
            c += Calcutation.Multi;
            c += Calcutation.Div;
            int rs = c(5, 3);

            Console.WriteLine("rs: " + rs);
            dd.Running();
        }
Beispiel #21
0
        public void preTreatment_addToOutput_IntegrationTest()
        {
            bool k = true;
            int  i = 0, n = polishRecord.Count();

            var proc = new Calculate();

            proc.expression = "w(x(3.14/2))";
            polishRecord.Add("3.14");
            polishRecord.Add("2");
            polishRecord.Add("x");
            polishRecord.Add("w");
            proc.preTreatment();
            while (i < n)
            {
                k  = polishRecord.ElementAt(i) == proc.polishRecord.ElementAt(i);
                i += 1;
            }
            Assert.IsTrue(k);
            proc = null;
        }
Beispiel #22
0
        public void Test_LjpCalculationMatches_NgAndBarry002()
        {
            /* LJP for this test came from Ng and Barry (1994) Table 2 */

            // 150 mM NaCl : 150 mM KCl
            // Na (150), Cl (150) : K (150) Cl (150)
            var ionSet = new List <Ion>
            {
                new Ion("Na", 150, 0),
                new Ion("K", 0, 150),
                new Ion("Cl", 150, 150)
            };

            var ionTable = new IonTable();

            ionSet = ionTable.Lookup(ionSet);

            var ljp = Calculate.Ljp(ionSet);

            Assert.AreEqual(-4.3, ljp.mV, 0.5);
        }
        public void 第一集買了一本_第二集也買了一本_價格應為190()
        {
            //arrange
            var target = new Calculate();
            var list   = new List <Book>()
            {
                new Book {
                    Type = type.第一集
                },
                new Book {
                    Type = type.第二集
                }
            };
            var expected = 190;

            //act
            var actual = target.Sum(list);

            //assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #24
0
    public static float calculate(Calculate calType, float origin, float value, out float delta)
    {
        float temp = 0;

        switch (calType)
        {
        case Calculate.Add:
            temp = origin + value;
            break;

        case Calculate.Multiply:
            temp = origin * value;
            break;

        case Calculate.Power:
            temp = (float)Mathf.Pow(origin, value);
            break;
        }
        delta = temp - origin;
        return(temp);
    }
Beispiel #25
0
    public override void OnActivate()
    {
        if (this.currentAmmoCount > 0)
        {
            int RND  = Random.Range(-1, 1);
            int RND2 = Random.Range(-2, 2);

            if (this.currentReloadTime <= 0)
            {
                Vector3 bulletDirection = Calculate.DirectionFromAngle(this.transform.eulerAngles + new Vector3(RND, RND2, 0));
                Vector3 position        = this.transform.GetChild(0).position + bulletDirection * .2f;

                GameObject bulletClone = Instantiate(bulletPrefab, position, this.transform.rotation) as GameObject;
                bulletClone.transform.localScale = new Vector3(0.05f, .05f, .05f);
                bulletClone.GetComponent <LasBolt>().Init(bulletDirection, BULLET_SPEED, BULLET_RANGE);

                this.currentReloadTime = MAX_RELOAD_TIME;
                this.currentAmmoCount--;
            }
        }
    }
Beispiel #26
0
        public void TestTriangleArea()
        {   //Arrange
            RightTriangle triangle = new RightTriangle()
            {
                SideA = 5, SideC = 5
            };

            //Act
            try
            {
                double area = Calculate.makeCalculation(triangle);
            }
            catch (NotImplementedException notImp)
            {
                Console.WriteLine(notImp.Message);
            }


            //Assert
            Assert.AreEqual(12, area);
        }
Beispiel #27
0
    private void OnCollisionEnter2D(Collision2D collision)
    //private void OnTriggerEnter2D(Collider2D collision)
    {
        Character target = collision.gameObject.GetComponentInChildren <Character>(); // Если компонент такого типа найден иначе null

        //Character target = collision.gameObject.GetComponentInChildren<Character>(); // Если компонент такого типа найден иначе null

        if (target != null)
        {
            /*
             * // Проверка класса на совместимость с типои данных
             * if (target is EnemyShipCharacter) {
             *  target.TakeDamage(_damage);
             * } else if (target is EnemyTowerCharacter) {
             *  target.TakeDamage(_damage*10);
             * }*/

            target.TakeDamage(Calculate.CalculateDamage(_damage, _typeProjectTile, target.GetArmorType()));
        }
        Destroy(gameObject);
    }
Beispiel #28
0
        public void RunExample()
        {
            Calculate add = (x, y) =>
            {
                Console.WriteLine("add");
                return(x + y);
            };

            Console.WriteLine(add(1, 2));

            Calculate mult = (x, y) =>
            {
                Console.WriteLine("mult");
                return(x * y);
            };

            Console.WriteLine(mult(1, 2));

            Console.ReadKey();
            Console.WriteLine();
        }
        private bool CheckInput(string[] input, Calculate type)
        {
            for (int i = 0; i < input.Length; i++)
            {
                if (input[i] == "")
                {
                    return(false);
                }

                foreach (char a in input[i])
                {
                    if ((a < '0' || a > '9') && a != ',' && a != '.' && a != ' ' && a != '-')
                    {
                        return(false);
                    }
                }

                input[i] = input[i].Replace('.', ',');           // Dots are used as decimal points too
            }
            return(true);
        }
Beispiel #30
0
    public override void OnActivate()
    {
        if (currentAmmo >= 0)
        {
            if (this.currentReloadTime <= 0)
            {
                Text txtAmmo = GameObject.Find("UI/AmmoCounter").GetComponent <Text>();
                txtAmmo.text = "Ammo: " + currentAmmo + "/" + MAX_AMMO;

                Vector3 bulletDirection = Calculate.HeadingBasedDirection(this.transform.position, this.transform.eulerAngles);
                Vector3 position        = this.transform.GetChild(0).position + bulletDirection * .2f;

                GameObject bulletClone = Instantiate(bulletPrefab, position, this.transform.rotation) as GameObject;
                bulletClone.transform.localScale = new Vector3(0.05f, .05f, .05f);
                bulletClone.GetComponent <LasBolt>().Init(bulletDirection, BULLET_SPEED, BULLET_RANGE);

                this.currentReloadTime = MAX_RELOAD_TIME;
                currentAmmo--;
            }
        }
    }
Beispiel #31
0
        List<Point> DepthCore(IEnumerable<Point> source, Calculate calculator, CellPlayer color) {
            var result = new List<Point>();
            IComparable bestEstimate = null;

            foreach (Point location in source) {
                if (Board.GetStone(location) != CellPlayer.None)
                    continue;
                var calc = calculator(location, color);

                int compareResult = calc.CompareTo(bestEstimate);
                if (compareResult < 0)
                    continue;
                if (compareResult > 0) {
                    result.Clear();
                    bestEstimate = calc;
                }
                result.Add(location);
            }

            return result;
        }
Beispiel #32
0
        public void usingDelegates()
        {
            Calculate method = chooseMethod('+');   //if we passed a variable instead of +/* we could still use method
                                                    //without knowing which was inputted etc

            Delegates test = new Delegates();

            Console.Write("3 + 4 = ");
            method(3, 4);
            Console.Write(" vs ");
            Console.Write("3 + 4 = ");
            Delegates.Add(3, 4);

            method = chooseMethod('*');
            Console.Write("3 x 4 = ");
            method(3, 4);

            method = chooseMethod('#');
            Console.Write("3 # 4 = ");
            method(3, 4);
        }
        private void Button_Calculate_Click(object sender, EventArgs e)
        {
            decimal principal = 0m;
            decimal payment   = 0m;
            decimal interest  = 0m;
            decimal periods   = 0;

            bool success =
                decimal.TryParse(TextBox_Principal.Text, out principal) &&
                decimal.TryParse(TextBox_Payment.Text, out payment) &&
                decimal.TryParse(TextBox_Interest.Text, out interest) &&
                decimal.TryParse(TextBox_Periods.Text, out periods);

            if (!success)
            {
                App.ShowError("Invalid input");
                return;
            }

            TextBox_PresentValue.Text = decimal.Round(Calculate.PresentValue(principal, payment, interest, periods), 2, MidpointRounding.AwayFromZero).ToString("0.00");
        }
Beispiel #34
0
        static void Main(string[] args)
        {
            #region 심플람다
            Calculate calc = (a, b) => a + b;
            Console.WriteLine(calc(3, 4));
            #endregion

            #region 불필요한 부분 주석처리
            //Concatnate concat = (arr) =>
            //{
            //    string result = string.Empty; // = "";
            //    foreach (var item in arr)
            //    {
            //        result += $" {item}";
            //    }
            //    return result;
            //};
            #endregion
            Concatnate concat = new Concatnate(StrJoin);
            Console.WriteLine(concat(args));
        }
Beispiel #35
0
        static void Main(string[] args)
        {
            //anonymous methodのLamda式を生成
            Calculate calc = (a, b) => a + b;

            Console.WriteLine($"{3} + {4} : {calc(3,4)}");

            //anonymous methodのLamda文を生成
            Concatenate concat =
                (arr) =>
            {
                string result = "";
                foreach (string s in arr)
                {
                    result += s;
                }
                return(result);
            };

            Console.WriteLine(concat(args));
        }
        public async Task ExecuteAsync_ChangeOutput_ReturnsModifiedOutput()
        {
            var middleware = new PostProcessingMiddleware <Calculate, int>(
                new[]
            {
                new UseConstantValue()
            },
                null
                );

            var handler = (IQueryHandler <Calculate, int>) new SyncCalculateHandler();
            var query   = new Calculate();

            var result = await middleware.ExecuteAsync(
                new Calculate(),
                () => handler.HandleAsync(query, default),
                default
                );

            result.Should().Be(UseConstantValue.Value);
        }
Beispiel #37
0
        public void Test1()
        {
            Calculate        calculate        = new Calculate();
            CalculeteRequest calculeteRequest = new CalculeteRequest();

            calculeteRequest.MaxPointX = 10;
            calculeteRequest.MaxPointY = 9;
            List <Rovers> rover = new List <Rovers>();

            rover.Add(new Rovers {
                RoverName = "First Rover", RoverXCordinate = 2, RoverYCordinate = 3, Directions = Directions.W, RoverMove = "RM"
            });
            calculeteRequest.Rovers = rover;

            var result = calculate.Moving(calculeteRequest);

            var actualOutput   = $"{result[0].RoverXCordinate} {result[0].RoverYCordinate} {result[0].RoverDirection.ToString()} {result[0].Error}";
            var expectedOutput = "2 4 N False";

            Assert.AreEqual(expectedOutput, actualOutput);
        }
Beispiel #38
0
        public void AddOrUpdate(IAssetPair assetPair)
        {
            _readerWriterLockSlim.EnterWriteLock();

            try
            {
                if (_assetPairs.ContainsKey(assetPair.Id))
                {
                    _assetPairs.Remove(assetPair.Id);
                }

                _assetPairs.Add(assetPair.Id, assetPair);

                _assetPairsByAssets = GetAssetPairsByAssetsCache();
                _assetPairsIds      = Calculate.Cached(() => _assetPairs, CacheChangedCondition, p => p.Keys.ToImmutableHashSet());
            }
            finally
            {
                _readerWriterLockSlim.ExitWriteLock();
            }
        }
Beispiel #39
0
        public static Massive OpenFile()
        {
            string infilepath = null;

            ArrayList files = GetFilesFromConsole("ovm");

            if (files.Count > 1) //Мульти-открытие файлов
            {
                Massive m = new Massive();
                //Временно будем использовать m.infileslist немного не по назначению (для передачи списка файлов)
                m.infileslist = files.ToArray(typeof(string)) as string[];
                return(m);
            }

            if (files.Count == 1) //Обычное открытие
            {
                infilepath = files[0].ToString();
            }

            if (infilepath != null)
            {
                //создаём массив и забиваем в него данные
                Massive m = new Massive();
                m.infilepath  = infilepath;
                m.infileslist = new string[] { infilepath };

                //ищем соседние файлы и спрашиваем добавить ли их к заданию при нахождении таковых
                if (Settings.AutoJoinMode == Settings.AutoJoinModes.DVDonly && Calculate.IsValidVOBName(m.infilepath) ||
                    Settings.AutoJoinMode == Settings.AutoJoinModes.Enabled)
                {
                    m = GetFriendFilesList(m);
                }
                if (m != null)
                {
                    return(m);
                }
            }

            return(null);
        }
Beispiel #40
0
        private void ComboBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == Key.Enter || e.Key == Key.Return)
            {
                //Проверяем введённый текст
                ComboBox box  = (ComboBox)sender;
                string   text = box.Text.Trim();
                if (text.Length > 7)
                {
                    text = text.Substring(0, 7);                  //Удаляем лишнее
                }
                double ar = ParseAR(text);
                if (ar < 0.5 || ar > 5)
                {
                    UndoEdit(box); return;
                }

                text = Calculate.ConvertDoubleToPointString(ar, 4);
                if (Math.Abs(ar - 1.33) <= 0.01)
                {
                    text += " (4:3)";
                }
                else if (Math.Abs(ar - 1.77) <= 0.01)
                {
                    text += " (16:9)";
                }

                //Добавляем и выбираем Item
                if (!box.Items.Contains(text))
                {
                    box.Items.Add(text);
                }
                box.SelectedItem = text;
            }
            else if (e.Key == Key.Escape)
            {
                //Возвращаем исходное значение
                UndoEdit((ComboBox)sender);
            }
        }
        public ActionResult SalaryResult(SalaryView sw)
        {
            double IYPO   = _context.SalaryCalculationConstants.Where(x => x.SCCCode == "IYPO").Select(x => x.SCCRatio).FirstOrDefault();
            double IKVSPO = _context.SalaryCalculationConstants.Where(x => x.SCCCode == "IKVSPO").Select(x => x.SCCRatio).FirstOrDefault();
            double IGSSPO = _context.SalaryCalculationConstants.Where(x => x.SCCCode == "IGSSPO").Select(x => x.SCCRatio).FirstOrDefault();
            double IISO   = _context.SalaryCalculationConstants.Where(x => x.SCCCode == "IISO").Select(x => x.SCCRatio).FirstOrDefault();
            double IDVO   = _context.SalaryCalculationConstants.Where(x => x.SCCCode == "IDVO").Select(x => x.SCCRatio).FirstOrDefault();

            Calculate calculation = new Calculate();
            double    insurance   = calculation.EmployeeInsurance(sw.rawSalary, IYPO, IKVSPO, IGSSPO, IISO);

            string disability       = sw.disability;
            string married          = sw.married;
            string spouseWork       = sw.spouseWork;
            string retired          = sw.retired;
            int    numberOfChildren = sw.numberOfChildren;

            List <double> resultList = new List <double>();

            if (sw.hiddenBag == "Brüt")
            {
                for (int numberOfMonths = 1; numberOfMonths <= 12; numberOfMonths++)
                {
                    double salary = calculation.GrossToNet(sw.rawSalary, IYPO, IKVSPO, IGSSPO, IISO, numberOfMonths, IDVO, disability, married, spouseWork, retired, numberOfChildren);
                    resultList.Add(salary);
                }
            }
            else
            {
                for (int numberOfMonths = 1; numberOfMonths <= 12; numberOfMonths++)
                {
                    double salary = calculation.NetToGross(sw.rawSalary, IYPO, IKVSPO, IGSSPO, IISO, numberOfMonths, IDVO, disability, married, spouseWork, retired, numberOfChildren);
                    resultList.Add(salary);
                }
            }
            ViewBag.resultList = resultList;
            ViewBag.rawSalary  = sw.rawSalary;
            ViewBag.hiddenBag  = sw.hiddenBag;
            return(View());
        }
Beispiel #42
0
        public ActionResult Table(FormCollection Nesneler)
        {
            int a = Convert.ToInt32(Nesneler["Alternatif"]);
            int d = Convert.ToInt32(Nesneler["Durum"]);

            string[,] matris = new string[a, d];
            for (int i = 0; i <= matris.GetUpperBound(0); i++)
            {
                for (int j = 0; j <= matris.GetUpperBound(1); j++)
                {
                    matris[i, j] = Nesneler["Durum" + i + "" + j];
                }
            }

            Calculate calculate = new Calculate();


            int columns = calculate.MatrisKolonHesapla(matris);

            int rows = calculate.MatrisSatirHesapla(matris);

            string matrisBirlesim = "";

            for (int i = 0; i <= matris.GetUpperBound(0); i++)
            {
                for (int j = 0; j <= matris.GetUpperBound(1); j++)
                {
                    matrisBirlesim += matris[i, j] + "|";
                }
            }

            IntermediateMatris intermediate = new IntermediateMatris()
            {
                Birlestirilmismatris = matrisBirlesim,
                RowLength            = rows
            };


            return(RedirectToAction("Kriterler", "Kriter", intermediate));
        }
Beispiel #43
0
        static void Main(string[] args)
        {
            Calculate <double> operation = new Calculate <double>();

            while (true)
            {
                Console.WriteLine("select a"); double    a      = double.Parse(Console.ReadLine());
                Console.WriteLine("select symbol"); char symbol = char.Parse(Console.ReadLine());

                Console.WriteLine("select b"); double b = double.Parse(Console.ReadLine());


                switch (symbol)
                {
                case '+':
                    Console.Write(operation.DelSumma(a, b));
                    break;

                case '-':
                    Console.Write(operation.DelMinus(a, b));
                    break;

                case '*':
                    Console.Write(operation.DelMultimate(a, b));
                    break;

                case '/':

                    Console.Write(operation.DelDivide(a, b));
                    if (b == 0)
                    {
                        Console.WriteLine("We connot devide to zero");
                    }
                    break;

                case '!': return;
                }
                Console.ReadKey();
            }
        }
Beispiel #44
0
        public void Test_LjpCalculationMatches_NgAndBarry007()
        {
            /* LJP for this test came from Ng and Barry (1994) Table 2 */

            // 50 CaCl2 + 50 MgCl2 : 100 LiCl
            // Ca (50), Cl (200), Mg (50) : Li (100), Cl (100)
            var ionSet = new List <Ion>
            {
                new Ion("Ca", 50, 0),
                new Ion("Cl", 200, 100),
                new Ion("Mg", 50, 0),
                new Ion("Li", 0, 100)
            };

            var ionTable = new IonTable();

            ionSet = ionTable.Lookup(ionSet);

            var ljp = Calculate.Ljp(ionSet);

            Assert.AreEqual(-8.2, ljp.mV, 0.5);
        }
Beispiel #45
0
        private double ParseAR(string input)
        {
            double aspect = 0;

            //Определяем введённый аспект
            if (input.Length > 2 && (input.Contains(":") || input.Contains("/")))
            {
                int      n, d;
                string   out_ar = input.Replace("/", ":");
                string[] a      = out_ar.Split(new string[] { ":" }, StringSplitOptions.None);
                if (a.Length == 2 && int.TryParse(a[0], out n) && int.TryParse(a[1], out d))
                {
                    aspect = (double)n / (double)d;
                }
            }
            else
            {
                aspect = Calculate.ConvertStringToDouble(input);
            }

            return(aspect);
        }
Beispiel #46
0
        public void Test_LjpCalculationMatches_NgAndBarry006()
        {
            /* LJP for this test came from Ng and Barry (1994) Table 2 */

            // 100 KCl + 2 CaCl2 : 100 LiCl + 2 CaCl2
            // K (100), Cl (104), Ca (2) : Li (100), Cl (104), Ca (2)
            var ionSet = new List <Ion>
            {
                new Ion("Ca", 2, 2),
                new Ion("K", 100, 0),
                new Ion("Li", 0, 100),
                new Ion("Cl", 104, 104)
            };

            var ionTable = new IonTable();

            ionSet = ionTable.Lookup(ionSet);

            var ljp = Calculate.Ljp(ionSet);

            Assert.AreEqual(+6.4, ljp.mV, 0.5);
        }
 private void WhenCalculatorIsCalled()
 {
     _calculator = new Calculate();
 }
 private void RenderTrackSwatch(TrackData trackData, int trackOffset)
 {
     var calculate = new Calculate(trackData);
     var yOffset = SquareSize * trackOffset;
     WriteTrackInfo(trackData, yOffset);
     DrawExaggeratedMeans(calculate, yOffset);
 }
 public void Should_give_correct_mean()
 {
     var colours = new List<Colour>{_black, _white};
     var calculate = new Calculate(colours);
     Assert.That(calculate.MeanColour().ToString(), Is.EqualTo(_midGrey.ToString()));
 }
Beispiel #50
0
 //单目运算符的计算方法
 public void CalculateBrain(Calculate c)
 {
     if (operandStack.Count >= 1)
     {
         DisplayValue = c.Invoke(operandStack.Pop());
         btnEnter.PerformClick();
     }
 }
Beispiel #51
0
 public ConsoleOutput(TrackData data)
 {
     _track = data.Results.First();
     _calculate = new Calculate(data);
 }
 public void Calculator(Calculate obj)
 {
     int a = obj(5, 6);
     Console.WriteLine(a.ToString());
 }
 public static bool InstanceDelegate() {
   Delegates delegates = new Delegates();
   Calculate addDelegate = new Calculate(delegates.Add);
   int result = addDelegate(2, 3);
   return result == 5 ? true : false;
 }
 public static bool StaticDelegate() {
   Calculate staticAddDelegate = new Calculate(Delegates.StaticSub);
   int result = staticAddDelegate(5, 1);
   return result == 4 ? true : false;
 }