Example #1
0
        public void Enqueue(Calculation calculation)
        {
            Calculations.Enqueue(calculation);
            if (Calculations.Count > StackSize)
            {
                Calculations.Dequeue();
            }

        }
Example #2
0
		private void Button_Click(object sender, RoutedEventArgs e)
		{
			Calculation c = new Calculation(calculationInput.Text);
			string result_list;
			try
			{
				c.calculate();
				result_list = calculationInput.Text + " = " + c.getResult();// + "\n" + calculationOutput.Text;
			}
			catch (InvalidTokenException ite)
			{
				result_list = calculationInput.Text.Trim() + " ---> ERROR";
				#if ERRORMESSAGES
				result_list += ": "+ite.Message;
				#endif
			}
			catch (Exception ex)
			{
				result_list = calculationInput.Text.Trim() + " ---> ERROR";
				#if ERRORMESSAGES
				result_list += ": " + ex.Message;
				#endif
			}
			//calculationOutput.Items.Insert(0, result_list);
			//calculationOutput.Text = "+\n3\t4";
			calculationOutput.Text = result_list + '\n' + calculationOutput.Text;
		}
Example #3
0
 public Presenter(Form1 form1)
 {
     this.calc             = new Calculation();
     this.form1            = form1;
     this.form1.Calculate += Form1_Calculate;
 }
Example #4
0
 public Calculation(Calculation previous)
 {
     number1   = previous.number1;
     number2   = previous.number2;
     @operator = previous.@operator;
 }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="frmAddStrip"/> class.
 /// </summary>
 public frmAddStrip()
 {
     InitializeComponent();
     calculation = new Calculation(lstCalculationLines);
 }
 //clear display
 private void clearClick(object sender, RoutedEventArgs e)
 {
     setDisplay(" ");
     newCalc = new Calculation();
 }
 //turn calculator off
 private void offClick(object sender, RoutedEventArgs e)
 {
     setDisplay("Off");
     newCalc = new Calculation();
     isOff   = true;
 }