#pragma once
#define _USE_MATH_DEFINES
#define wWidth  800
#define wHeight 800
#include <iostream>
#include <cmath> // sqrt()
#include <vector>
using std::vector;
#include <SFML/Graphics.hpp>
using std::ostream;
using std::istream;

class Complex {
private:
	double real;
	double imag;
	double arg;
	double mod;
public:
	double getReal() const { return real;  }
	double getImag() const { return imag; }
	double getMod() const { return mod; }
	void setReal(double x)  { real = x; }
	void setImag(double y) { imag = y; }

	Complex(double x = 0., double y = 0.) : real(x), imag(y) {
		mod = std::sqrt(x*x + y * y);
		arg = atan2(x, y);
	}
	Complex operator+(const Complex& c) {
		return(Complex(real + c.real, imag + c.imag));
	}
	Complex operator-(const Complex& c) {
		return(Complex(real - c.real, imag - c.imag));
	}
	Complex operator*(const Complex& c) {
		return(Complex(real*c.real - imag*c.imag, 
					   imag*c.real + real*c.imag));
	}
	Complex operator/(const Complex& c) {
		return(Complex((real*c.real + imag*c.imag)/(c.mod*c.mod),
			           (imag*c.real - real*c.imag)/(c.mod*c.mod)));
	}
	Complex operator+=(const Complex& c) {
		return(*this + c);
	}

};

ostream& operator<<(ostream& os, const Complex& c) {
	os << '(' << c.getReal() << ',' << c.getImag() << ')';
	//c.getImag() < 0 ? os << " - " << -1.*c.getImag() << "*i)" : 
		//			  os << " + " << c.getImag() << "*i)";
	return os;
}

istream& operator>>(istream& is, Complex& c) {
	char c1{ 'a' }, c2{ 'a' }, c3{ 'a' };
	double realPart, imagPart;
	is >> c1 >> realPart >> c2 >> imagPart >> c3;
	if (c1 != '(' || c2 != ',' || c3 != ')') std::cerr << "trouble.";
	else {
		c.setReal(realPart);
		c.setImag(imagPart);
	}
	return is;
}