#include "trench.h"
#include <string.h>
#include <exception>
#include <stdio.h>
using namespace std;

Trench::Trench(int size, const char *colour, int price, int quantity, const char *photograph){
    this->_size = size;
    this->_colour = new char[255];
    strcpy(this->_colour,colour);
    this->_price = price;
    this->_quantity = quantity;
    this->_photograph=new char[255];
    strcpy(this->_photograph,photograph);
}

Trench::~Trench(){
    delete[] this->_colour;
    delete[] this->_photograph;
}

Trench::Trench(const Trench &trench){
    _size = trench.size();
    _colour = new char[255];
    strcpy(_colour,trench.colour());
    _price = trench.price();
    _quantity = trench.quantity();
    _photograph = new char[255];
    strcpy(_photograph,trench.photograph());
}

int Trench::size() const {
    return this->_size;
}

void Trench::size(int newSize){
    this->_size = newSize;
}

char* Trench::colour() const {
    return this->_colour;
}

void Trench::colour(const char *newColour){
    strcpy(this->_colour,newColour);
}

int Trench::price() const {
    return this->_price;
}

void Trench::price(int newPrice){
    this->_price = newPrice;
}

int Trench::quantity() const{
    return this->_quantity;
}

void Trench::quantity(int newQuantity){
    this->_quantity = newQuantity;
}

char* Trench::photograph() const {
    return this->_photograph;
}

void Trench::photograph(const char *newPhotograph){
    strcpy(this->_photograph, newPhotograph);
}

bool Trench::operator==(const Trench& t){
    if(this->_size==t.size() && strcmp(this->_colour,t.colour())==0 && strcmp(this->_photograph,t.photograph())==0){
        return 1;
    }
    return 0;
}

char* Trench::toString(){
    char* string = new char[256];
    sprintf(string,"Size: %d | Colour: %s | Price: %d | Quantity: %d | Photograph Link: %s \n",this->_size,this->_colour,this->_price,this->_quantity,this->_photograph);
    return string;
}