├── README.md └── tp2.cs /README.md: -------------------------------------------------------------------------------- 1 | # test-demo-tp2-cs 2 | Tp2 of C# course 3 | 4 | ![tp2cs](https://user-images.githubusercontent.com/40203497/121748402-c5913b00-cb00-11eb-9604-31c857b0196b.png) 5 | 6 | -------------------------------------------------------------------------------- /tp2.cs: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | **@author selim 4 | */ 5 | 6 | namespace CSharpprogram { 7 | 8 | class Complex { 9 | 10 | public int A { get; set; } 11 | public int B { get; set; } 12 | 13 | public int GetA() { 14 | return this.A; 15 | } 16 | 17 | // GETTERS &&&&& SETTERS old way ;) 18 | 19 | /* 20 | public void SetA(int A) { 21 | this.A = A; 22 | } 23 | 24 | public int GetB() { 25 | return this.B; 26 | } 27 | 28 | public void SetB(int B) { 29 | this.B = B; 30 | } 31 | */ 32 | 33 | public Complex(int A, int B) { 34 | this.A = A; 35 | this.B = B; 36 | } 37 | 38 | public override string ToString() { 39 | return " (" + this.A + ", " + this.B + ") "; 40 | } 41 | 42 | public double GetMagnitude() { 43 | return Math.Sqrt(this.A + this.B); 44 | } 45 | 46 | public int Sum(Complex c1, Complex c2) { 47 | this.A = c1.GetA() + c2.GetB(); 48 | this.B = c1.B + c2.B; 49 | return this.A + this.B; 50 | } 51 | 52 | 53 | 54 | } 55 | 56 | } 57 | 58 | 59 | 60 | --------------------------------------------------------------------------------