/*Implementation of Label.h

It contains the member functions of Label

*/

#include "Label.h"

//Constructor functions:
//------------------------------------------------------------------------------------

//Copy Constructor
Label::Label(const Label &OriginalLabel)
	: Cost(OriginalLabel.Cost), Load(OriginalLabel.Load), NumberOfCustomers(OriginalLabel.NumberOfCustomers), LastLocation(OriginalLabel.LastLocation), PreviousLabel(OriginalLabel.PreviousLabel)
{

	if (!(OriginalLabel.Reachable == 0 || NumberOfCustomers == 0)){
		Reachable = new bool[NumberOfCustomers];
		for (short int i = 0; i<NumberOfCustomers; i++){
			Reachable[i] = OriginalLabel.Reachable[i];
		}
	}
	else{
		Reachable = 0;
	}

}

//Operator functions:
//------------------------------------------------------------------------------------

//Assignment operator
Label& Label::operator =(const Label& OriginalLabel){

	//Copy
	Cost = OriginalLabel.Cost;
	Load = OriginalLabel.Load;
	NumberOfCustomers = OriginalLabel.NumberOfCustomers;
	delete[]Reachable;
	if (!(OriginalLabel.Reachable == 0 || NumberOfCustomers == 0)){
		Reachable = new bool[NumberOfCustomers];
		for (short int i = 0; i<NumberOfCustomers; i++){
			Reachable[i] = OriginalLabel.Reachable[i];
		}
	}
	else{
		Reachable = 0;
	}
	LastLocation = OriginalLabel.LastLocation;
	PreviousLabel = OriginalLabel.PreviousLabel;

	return *this;

}

//Destructor functions
//------------------------------------------------------------------------------------

//Default destructor
Label::~Label(){

	delete[]Reachable;

}

//Print functions
//------------------------------------------------------------------------------------

//Print resources
void Label::PrintResources(){

	//Print
	std::cout << "Cost:           " << Cost << std::endl;
	std::cout << "Load:           " << Load << std::endl;
	std::cout << "Last Location:  " << LastLocation << std::endl;
	std::cout << "Location resourses: " << std::endl;
	for (short int i = 0; i<NumberOfCustomers; i++){
		std::cout << i+1 << " " << Reachable[i] << std::endl;
	}

}