Exemple #1
0
        //****************************************************************************************************
		public override bool MoreThan(SingleVar b) {
			if (!b.IsString())
				throw new CalcException("Ќеправильные операнды.");
			else {
				return b.ToString().CompareTo(m_val) < 0;
			}
		}
Exemple #2
0
        //****************************************************************************************************
		public void setAt(int index, SingleVar var) {
			if (var == null) {
				throw new CalcException("ќшибка");
			}
			if (index < 0)
				throw new CalcException("»ндекс не может быть отрицательным");
			for (int ind = index, s = m_list.Count; ind >= s; ind--)
				m_list.Add(null);
			m_list[index] = var.Clone();
		}
Exemple #3
0
        //****************************************************************************************************
		public override SingleVar add(SingleVar b) {
			if (b.IsNum()) {
				try {
					return new RealVar(this.m_val + ((NumVar) b).ToDouble());
				}
				catch (Exception) {
					throw new CalcException("Ошибка в вычислениях.");
				}
			}
			else
				throw new CalcException("Неправильные операнды.");
		}
Exemple #4
0
        //****************************************************************************************************
		public override SingleVar add(SingleVar b) {
			if (b.IsInt())
				return new IntVar(this.m_val + ((IntVar) b).Val);
			else if (b.IsReal()) {
				try {
					return new RealVar((double) this.m_val + ((RealVar) b).Val);
				}
				catch (System.SystemException) {
					throw new CalcException("ќшибка в вычислени¤х.");
				}
			}
			else
				return null;
		}
Exemple #5
0
		public void AssignToElement(SingleVar var, string name, int index) {
			Pair p;
			if (m_n != 0) {
				int i = 0;
				do {
					p = (m_list[i++] as Pair);
					if (p.m_str == name) {
						if (!p.m_var.IsArray())
							throw new CalcException("ѕеременна¤ не ¤вл¤етс¤ массивом");
						(p.m_var as ArrayVar)[index] = var;
						return;
					}
				} while (i < m_n);
			}
			p = new Pair();
			p.m_var = new ArrayVar();
			(p.m_var as ArrayVar)[index] = var;
			p.m_str = name;
			m_list.Add(p);
			m_n++;
		}
Exemple #6
0
        //****************************************************************************************************
		public SingleVar be(SingleVar b) {
			return new IntVar(this.ToBool() == b.ToBool());
		}
Exemple #7
0
        //****************************************************************************************************
		public IntVar xor(SingleVar b) {
			bool p = this.ToBool();
			bool q = b.ToBool();
			return new IntVar(((!p) && q) || (p && (!q)));
		}
Exemple #8
0
        //****************************************************************************************************
		public IntVar or(SingleVar b) {
			return new IntVar(this.ToBool() || b.ToBool());
		}
Exemple #9
0
        //****************************************************************************************************
		public IntVar and(SingleVar b) {
			return new IntVar(this.ToBool() && b.ToBool());
		}
Exemple #10
0
        //****************************************************************************************************
		public IntVar ge(SingleVar b) {
			return new IntVar(!b.MoreThan(this));
		}
Exemple #11
0
        //****************************************************************************************************
		public IntVar ne(SingleVar b) {
			return new IntVar(!this.Equals(b));
		}
Exemple #12
0
        //****************************************************************************************************
		public IntVar lt(SingleVar b) {
			return new IntVar(b.MoreThan(this));
		}
Exemple #13
0
        //****************************************************************************************************
        public IntVar eq(SingleVar b) {
			return new IntVar(this.Equals(b));
		}
Exemple #14
0
        //****************************************************************************************************
		public abstract bool MoreThan(SingleVar b);
Exemple #15
0
        //****************************************************************************************************
		public abstract SingleVar add(SingleVar b);
Exemple #16
0
        //****************************************************************************************************
		public override SingleVar add(SingleVar b) {
			return new StringVar(this.m_val + b.ToString());
		}
Exemple #17
0
        //****************************************************************************************************
		public IntVar le(SingleVar b) {
			return new IntVar(!this.MoreThan(b));
		}
Exemple #18
0
        //****************************************************************************************************
		public IntVar gt(SingleVar b) {
			return new IntVar(this.MoreThan(b));
		}
Exemple #19
0
        //****************************************************************************************************
		public override bool MoreThan(SingleVar b) {
			if (!b.IsNum())
				throw new CalcException("Ќеверные типы операндов");
			return this.ToDouble() > ((NumVar) b).ToDouble();
		}