#include <iostream>

#include "Complex.h"

using namespace std;

int Complex::numberInstances = 0;
const Complex Complex::J(0,1);

ostream& operator<<(ostream& s, const Complex& z){
    return s <<"(" <<z.getReal() <<","<<z.getImaginary()<<")";
}


Complex Complex::operator+(Complex& c2){
    return Complex(this->getReal()+c2.getReal(),this->getImaginary()+c2.getImaginary());
}

Complex Complex::operator+(double d){
    return Complex(this->getReal()+d,this->getImaginary());
}

Complex operator+(double d, const Complex& c){
    return Complex(c.getReal()+d,c.getImaginary());
}


Complex Complex::operator*(Complex& c2){
    return Complex(this->getReal()*c2.getReal()-this->getImaginary()*c2.getImaginary(),this->getReal()*c2.getImaginary()+ this->getImaginary()*c2.getReal());
}

Complex Complex::operator-(Complex& c2){
    return Complex(this->getReal()-c2.getReal(),this->getImaginary()-c2.getImaginary());
}



Complex::Complex(double real, double imaginary  =0){
    Complex::numberInstances++;
    this->real = real;
    this->imaginary = imaginary;
}

double Complex::getReal() const{
    return this->real;
}

double Complex::getImaginary() const{
    return this->imaginary;
}

int Complex::getNumberInstances(){
    return Complex::numberInstances;

}
