Esempio n. 1
0
 public override void addOpperand(Calc calc,Complex c)
 {
     //calc.Opperand1=calc.Total;
     //calc.Opperand2=c;
     calc.Total=c;
     calc.CurrentState=OpperandEnteredState.Singleton;
 }
Esempio n. 2
0
 public override void addOpperand(Calc calc, Complex c)
 {
     //calc.CurrentState = ErrorState.Singleton;
     //throw new Exception("Cannot add opperand in opperand entered state");
     calc.setDisplay(c.ToString());
     calc.CurrentState = OpperandEnteredState.Singleton;
 }
Esempio n. 3
0
 public override void addOpperator(Calc calc, IBinOp op)
 {
     calc.Total=Complex.Parse(calc.getDisplay());
     calc.pending_op = op;
     calc.setDisplay("");
     calc.CurrentState = OpperatorEntredState.Singleton;
 }
        public override void addOpperand(Calc calc, Complex c)
        {
            //just replace current w/ this
            calc.setDisplay(c.ToString());

            calc.CurrentState = OpperandEnteredState.Singleton;
        }
 public override void addOpperator(Calc calc, IBinOp op)
 {
     calc.pending_op = op;
     calc.setDisplay("");
     calc.CurrentState = OpperatorEntredState.Singleton;
     //calc.CurrentState=ErrorState.Singleton;
     //throw new Exception("cant add opperator in opperator entered state");
 }
Esempio n. 6
0
 public override void enterDigit(Calc calc, char c)
 {
     Console.WriteLine("Start State: enter character " + c);
     calc.setDisplay("" + c);
     if ('0' != c)
     {
         calc.CurrentState = AccumState.Singleton;
     }
 }
 public override void Calculate(Calc calc)
 {
     Complex total = calc.pending_op.compute(calc.Total, Complex.Parse(calc.getDisplay()));
     calc.setDisplay(total.ToString());
     calc.Total = total;
     calc.CurrentState = CompState.Singleton;
     //calc.CurrentState=ErrorState.Singleton;
     //throw new Exception("you cant do a calculation right after you add an opperator, need another opperand");
 }
        public override void addOpperand(Calc calc, Complex c)
        {
            //calc.Opperand1=calc.Total;
            //calc.Opperand2=c;
            calc.setDisplay(c.ToString());
            //			Complex result = calc.pending_op.compute(calc.Total, calc.Opperand2);
            //			calc.Total=result;
            //			calc.Opperand1=result;

            //why did I do this???
            //calc.pending_op=null;

            calc.CurrentState=OpperandEnteredState.Singleton;
            //calc.CurrentState=CompState.Singleton;
        }
        public override void Calculate(Calc calc)
        {
            if (calc.pending_op != null) {
                Complex opperand = Complex.Parse(calc.getDisplay());

                Complex total = calc.pending_op.compute(calc.Total, opperand);
                //calc.Opperand1=total;
                calc.Total = total;
                calc.setDisplay(total.ToString());

                calc.CurrentState = CompState.Singleton;
            } else {
                calc.CurrentState=ErrorState.Singleton;
            //				throw new Exception("cannot do calculation w/o pending opperator");
            }
        }
Esempio n. 10
0
 public override void Calculate(Calc calc)
 {
     calc.CurrentState = (ErrorState.Singleton);
     throw new Exception ("cannot do calculation when no expressions have been entered --- in the start state");
 }
Esempio n. 11
0
 public override void addOpperator(Calc calc, IBinOp op)
 {
     calc.CurrentState = ErrorState.Singleton;
     //throw new Exception ("cannot add opperator when an opperand has not been entered yet!");
 }
Esempio n. 12
0
 public override void addOpperand(Calc calc, Complex c)
 {
     //calc.Total=new Complex(0,0);
     calc.setDisplay(c.ToString());
     calc.CurrentState = OpperandEnteredState.Singleton;
 }
Esempio n. 13
0
 public abstract void addOpperator(Calc calc, IBinOp op);
Esempio n. 14
0
 public Form1()
 {
     InitializeComponent();
     calc = new Calc();
 }
Esempio n. 15
0
 public override void Calculate(Calc calc)
 {
     throw new NotImplementedException ();
 }
 public override void enterDigit(Calc calc, char c)
 {
     throw new NotImplementedException();
 }
Esempio n. 17
0
 public abstract void enterDigit(Calc calc, char c);
Esempio n. 18
0
 public abstract void Calculate(Calc calc);
Esempio n. 19
0
 public override void enterDigit(Calc calc, char c)
 {
     Console.WriteLine("Accumulate State: enter character " + c);
     calc.setDisplay(calc.getDisplay() + c);
     calc.CurrentState = AccumState.Singleton;
 }
Esempio n. 20
0
 public override void addOpperator(Calc calc, IBinOp op)
 {
     //calc.Opperand1=calc.Total;
     calc.pending_op=op;
     calc.CurrentState=OpperatorEntredState.Singleton;
 }
Esempio n. 21
0
 public override void Calculate(Calc calc)
 {
 }
Esempio n. 22
0
 public override void enterDigit(Calc calc, char c)
 {
     //Complex c=Complex.Parse(calc.getDisplay());
     throw new NotImplementedException();
 }
 public override void enterDigit(Calc calc, char c)
 {
     Console.WriteLine("OpperatorEntredS State: enter character " + c);
     calc.setDisplay( c.ToString());
     calc.CurrentState = AccumState.Singleton;
 }
Esempio n. 24
0
 public abstract void addOpperand(Calc calc, Complex c);