#include "domain.h"
#include "string.h"



Bill::Bill(){

}

Bill::Bill(char* company_name,char* serial_number,int sum,bool isPaid){
    this->_company_name = new char[strlen(company_name)+1];
    strcpy(this->_company_name,company_name);
    this->_serial_number = new char[strlen(serial_number)+1];
    strcpy(this->_serial_number,serial_number);
    this->_sum = sum;
    this->_isPaid = isPaid;
}

Bill::~Bill(){
    delete[] this->_company_name;
    delete[] this->_serial_number;
}

Bill::Bill(const Bill& bill){
    _company_name = new char[strlen(bill.company_name())+1];
    strcpy(_company_name,bill.company_name());
    _serial_number = new char[strlen(bill.serial_number())+1];
    strcpy(_serial_number,bill.serial_number());
    _sum = bill.sum();
    _isPaid = bill.isPaid();
}

char* Bill::company_name() const{
    return this->_company_name;
}

char* Bill::serial_number() const{
    return this->_serial_number;
}

int Bill::sum() const{
    return this->_sum;
}

bool Bill::isPaid() const{
    return this->_isPaid;
}

void Bill::company_name(char* company_name){
    delete[] this->_company_name;
    this->_company_name = new char[strlen(company_name)+1];
    strcpy(this->_company_name,company_name);
}

void Bill::serial_number(char* serial_number){
    delete[] this->_serial_number;
    this->_serial_number = new char[strlen(serial_number)+1];
    strcpy(this->_serial_number,serial_number);
}

void Bill::sum(int sum){
    this->_sum = sum;
}

void Bill::isPaid(bool check){
    this->_isPaid = check;
}

bool Bill::operator==(Bill bill){
    return strcmp(this->_serial_number,bill.serial_number()) == 0;
}

Bill& Bill::operator=(const Bill& bill){
    this->_company_name = new char[strlen(bill.company_name())+1];
    strcpy(this->_company_name,bill.company_name());
    this->_serial_number = new char[strlen(bill.serial_number())+1];
    strcpy(this->_serial_number,bill.serial_number());
    this->_sum = bill.sum();
    this->_isPaid = bill.isPaid();
    return *this;
}