-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomTypes.cs
85 lines (68 loc) · 2.25 KB
/
CustomTypes.cs
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
using System;
using ComplexNumber;
namespace ComplexNumber
{
public struct RealPart //new type for real part of complex number
{
private Double value;
public RealPart(Double value) //parametrized constructor
{
this.value = value;
}
public Double add(RealPart number) //method to add two real parts
{
return this.value + number.value;
}
public Double substract(RealPart number) //method to substract two real parts
{
return this.value - number.value;
}
public Double multiply(RealPart number) //method to multiply two real parts
{
return this.value * number.value;
}
public Double multiply(ImaginityPart number)//method to multiply a real and an imaginity parts
{
return this.value * number.getValue();
}
public Double getSquare() // return square of the value
{
return getValue() * getValue();
}
public Double getValue() // return the value
{
return this.value;
}
}
public struct ImaginityPart //new type for imaginity part of complex number
{
private Double value;
public ImaginityPart(Double value) //parametrized constructor
{
this.value = value;
}
public Double add(ImaginityPart number) //method to add two imaginity parts
{
return this.value + number.value;
}
public Double substract(ImaginityPart number)//method to substract two imaginity parts
{
return this.value - number.value;
}
public Double multiply(ImaginityPart number)//method to multiply two imaginity parts
{
return -this.value * number.getValue(); // return - because of i*i
public Double multiply(RealPart number)//method to multiply a real and an imaginity parts
{
return this.value * number.getValue();
}
public Double getSquare() // return square of the value
{
return getValue() * getValue();
}
public Double getValue() // return the value
{
return this.value;
}
}
}