/* Ramis Aksakov 1111-01 Задачи L3 */ using System; namespace HomeWorkInterfaces.L3.Aksakov { class Div : Expression { private Number a = null; private Number b = null; private Variable c = null; private Variable f = null; private String S; private Expression Ex; private Variable t = null; private Boolean fr = false; public Div(Number a1, Variable b1) { this.a = a1; this.c = b1; } public Div(Number a1, Number b1) { this.a = a1; this.b = b1; } public Div(Number a1, Variable b1, Variable t) { this.a = a1; this.c = b1; this.t = t; } public Div(Variable a1, Variable b1) { this.c = a1; this.f = b1; } public Div(Variable a1, Number b1, Boolean fr) { this.c = a1; this.a = b1; this.fr = fr; } public override string Show() { if ((a != null) && (c != null) && (t==null) && (fr == false)) { S = a.Chislo + "/" + c.variable; } else if ((a != null) && (b != null)) { S = a.Chislo + "/" + b.Chislo; } else if ((c != null) && (f != null)) { S = c.variable + "/" + f.variable; } else if ((a != null) && (t != null)) { S = a.Chislo + "/" + c.variable + "^2"; } else if ((a == null) && (b == null) && (c==null) && (f == null)) { S = "0"; } else if ((c != null) && (f == null) && (a == null) && (b==null)) { S = "0"; } else if ((a != null) && (c == null) && (fr == false) && (t == null)) { S = "1/" + a.Chislo; } else if ((a != null) && (c != null) && (fr == true) && (t==null)) { S = c.variable + "/" + a.Chislo; } return S; } public override Expression Diff() { if ((a != null) && (c != null)) { String str = this.Show(); if ((str[2].ToString()).Equals(a.Chislo.ToString())) { c = null; Ex = new Div(c, a, false); } else { t = new Variable('w'); a = new Number(-a.Chislo); Ex = new Div(a, c, t); } } else if ((a != null) && (b != null)) { a = null; b = null; Ex = new Div(a, b); } else if ((c != null) && (f != null)) { f = null; Ex = new Div(c, f); } return Ex; } } }