Hello everyone.
So I hope for Glass is no clear to you all.
If it is not clear then please do it again.
Try to create friction glass on your own.
In this session I will discuss a problem that you guys will implement.
I am just giving you a brief introduction on how to implement it.
In the last session we implemented refreshing glass.
So now you guys have to implement complex no glass so enmeshed complex.
So in metals.
There are complex numbers so a complex number is like we have a real part and we have imaginary part
real part and imaginary part.
This is called order.
Some people represented with g or so but prefer this i okay So example is three plus four I order.
Okay so this is a complex number so complex number is two parts real part and imaginary part.
So how we will implement this glass how we will implement complex no glass.
So first of all we will have two private properties two private data members real and imaginary so these
will be two private data members to private properties.
Okay so they both will be private.
Now let's see
so let's say this line line.
MARTIN So what is this.
It is a constructor so this is a paramedic's constructor and this better amortized constructor is taking
two values first.
The real part and second is the imaginary part.
Okay so for example how we will create object so a complex number name of the class when and legendary
all parties 3 and the imaginary part is 5.
So what will happen in the paramedics constructor a real part will be set to three real part will become
three and the imaginary part will become five okay.
Dale Bartlett welcome to reimagining but will become five.
So I am using parameters constructor here.
So wipe Adam or those constructor because if a user wants to create object of my class he has to give
the value of real part and they match any part.
So my real or imagined part will never contain garbage value.
Okay they will never contain garbage value.
After that I will take a choice as input from the user.
So if the choice is one I am calling a function.
C1 dart plus C2.
So plus is a function plus a function that you guys will implement.
So what best function will do.
It will add to complex number.
So C2 is a barometer to the argument of type complex number.
Okay so what display function will do.
It will add to complex numbers and put that is our even.
So add two complex numbers see when plus you two and put that in there didn't see one.
Just like we did in the faction class we will add two complex number and four that is in complex numbers
even.
Okay so you two will remain unchanged.
CO2 remains unchanged.
OK so what is that.
But rather than type of the plus function we don't have will be void.
We are not attending anything.
Okay so how do I do complex number.
So suppose 7 is 3 plus 4 iota and c 2 is 5 plus one iota.
So what will be C when plus you to see plus you two will be real part plus real part.
So eight plus five.
IOTA okay.
So this will be our new value of seven.
So this will become C1 and C2 will remain unchanged.
CO2 remains unchanged.
So this is how we are a complex number.
So you have to compare this plus function you have to write this plus function.
And then after doing plus after doing plus operation what we are doing we are printing we are printing.
So how we will print we will print real part first then plus then iota and then imaginary part.
Okay.
So this is how we print a complex number.
So what if the choice is.
If the choice is to I have a function called C1 multiply.
So he went out multiply C2.
So this multiply is a function that you guys have to implement.
So this multiply function doesn't have any return type of return type is void and it will take object
of type complex number.
Okay.
So this.
So this multiply function what will do.
It will take to complex number 7 as you do multiply them and put there is urgency when.
Okay so multiply too complex the embassy went into you 2 and put that urgency when you two will remain
unchanged.
Okay.
So do you guys know how to multiply two complex number.
So I am just giving you of beef idea so let's say C when is three plus 4 I order and C two is five plus
one iota.
So C when multiplies you to so first of all real part multiply really part.
So three into five with a negative sign.
Why negative sign.
Because I would test queries minus one and then imagine about my GPA imaginary part so forward into
one.
So this will be your real part.
Now it's time for the imaginary part.
So I order so imaginary part will be three to one plus four and do five.
Okay so what is the formula.
Formula is very simple.
A real part of C1 real part C1 multiply real part C two negative sine imaginary Part C even multiply
imaginary part C two.
So this will be your real and the imaginary part will be a real part of C1 multiply imaginary part of
C2 plus sine real part of C to multiply imaginary part of C even.
Okay so this is the formula for multiplying two complex number.
I hope you guys already know this formula but in case you would run.
No I just gave you the formula.
So what we are doing here is after the multiplication we are printing seven seven dot print.
So print is also a function print is also a function so print is not taking any argument and the return
type will be void.
Okay so best of luck guys.
I hope you will be able to implement it very easily.
Okay.
Thank you.