// A simple class 4
// Date 22:40 31/10/2016
// By Ben a.k.a DreamVB

#include <iostream>
#include <time.h>

using namespace std;
using std::cout;
using std::endl;

class CBox{
private:
	double m_length = 0;
	double m_width = 0;
	double m_height = 0;

public:
	//Default constructor
	CBox(){
		m_width = m_height = m_length = 2.5;
	}

	CBox(double length, double width, double height){
		m_length = length;
		m_width = width;
		m_height = height;
	}

	double Volume() const{
		return m_length*m_width*m_height;
	}

	int BoxCompare(CBox& otherbox){
		if (this->Volume() > otherbox.Volume()){
			return 1;
		}
		else if (this->Volume() < otherbox.Volume()){
			return -1;
		}
		else{
			return 0;
		}
	}

	double GetLength()const { return m_length; }
	double GetWidth() const { return m_width; }
	double GetHeight() const{ return m_height; }
	
	bool operator<(CBox &thebox){
		return(this->Volume() < thebox.Volume());
	}

	bool operator>(CBox &thebox){
		return(this->Volume() > thebox.Volume());
	}

};

int GetRandNum(){
	return 1 + std::rand() % 100 + 1.1;
}

int main(int argc, char *argv[]){
	const int total = 30;
	int i = 0;
	CBox *boxptr;

	srand(time(0));

	CBox boxes[total];

	while (i < total){
		boxes[i] = CBox(GetRandNum(), GetRandNum(), GetRandNum());
		i++;
	}

	i = 0;
	//Print out boxes.
	while (i < total){
		cout << "Box " << i << endl;
		cout << "Length : " << boxes[i].GetLength() << endl;
		cout << "Width  : " << boxes[i].GetWidth() << endl;
		cout << "Height : " << boxes[i].GetHeight() << endl;
		cout << "Volume : " << boxes[i].Volume() << endl << endl;
		i++;
	}

	i = 0;
	//Find the bxoes highest volume.
	boxptr = &boxes[0];

	while (i < total){
		if (*boxptr < boxes[i]){
			boxptr = &boxes[i];
		}
		i++;
	}

	cout << endl;
	cout << "The largest box in the list is :" << endl;

	cout << "Length : " << boxptr->GetLength() << endl;
	cout << "Width  : " << boxptr->GetWidth() << endl;
	cout << "Height : " << boxptr->GetHeight() << endl;
	cout << "Volume : " << boxptr->Volume() << endl << endl;



	system("pause");
	return 0;
}
