/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   Point.class.cpp                                    :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: Bastien Chanot <chanot.bastien@gmail.com>  +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2025/07/18 19:15:01 by Bastien Chanot    #+#    #+#             */
/*   Updated: 2025/07/18 19:16:41 by Bastien Chanot   ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "Point.class.hpp"
#include <iostream>

Point::Point(void) : _x(0), _y(0) {
	std::cout << "Default constructor called" << std::endl;
	return ;
}

Point::Point(Point const &src) : _x(src._x), _y(src._y) {
	std::cout << "Copy constructor called" << std::endl;
	return ;
}

Point::Point(float const &x, float const &y) : _x(Fixed(x)), _y(Fixed(y)) {
	std::cout << "Args constructor called" << std::endl;
	return;
}

Point::~Point(void) {
	std::cout << "Default destructor called" << std::endl;
	return ;
}

Fixed		Point::getX(void) const {
	return(this->_x);
}

Fixed		Point::getY(void) const {
	return(this->_y);
}

Point		&Point::operator=(Point const &rhs) {
	std::cout << "Copy assignment operator called" << std::endl;
	if (this == &rhs)
		return *this;

	Point tmp(rhs);

	this->~Point();
	new (this) Point(tmp);
	return *this;
}