Ramis Aksakov 1111-01 Задачи L3 using System namespace HomeWorkInterfa

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
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;
}
}
}