public Operation Clone() { Operation op; if (this is Addition) { op = new Addition(); } else if (this is Soustraction) { op = new Soustraction(); }else if (this is Multiplication) { op = new Multiplication(); } else if (this is Division) { op = new Division(); } else { op = new sqrt(); } op.setOperandeA(this.operandeA); op.setOperandeB(this.operandeB); return op; }
public void Analyser(string expression) { var pos = expression.LastIndexOf('+'); if (pos == -1) { pos = expression.LastIndexOf('-'); } if (pos == -1) { // Valeur this.Droite = new Atome(); this.Droite.Analyser(expression); this.Gauche = null; } else { // Multiplication + Valeur this.Gauche = new Addition(); this.Gauche.Analyser(expression.Substring(0, pos - 1)); this.Droite = new Atome(); this.Droite.Analyser(expression.Substring(pos + 1)); } }
public void Analyser(string expression) { this.Addition = new Addition(); this.Addition.Analyser(expression.Replace(" ", "")); }
public void Analyser(string expression) { if (expression.StartsWith("(")) { if (expression.EndsWith(")")) { this.Addition = new Addition(); this.Addition.Analyser(expression.Substring(1, expression.Length - 2)); this.Constante = null; } else throw new Exception("Pas de parenthèse de fin"); } else { this.Constante = double.Parse(expression); this.Addition = null; } }