
//File PhoneNumber.h - contains definition of PhoneNumber class

#ifndef _phonenumber_h
#define _phonenumber_h

#include <sstream>

class PhoneNumber{		//Structure taken from Name class

 public:
	PhoneNumber(const char * aCode, const char * oCode, const char * sCode){
		areaCode = new string(aCode);
		officeCode = new string(oCode);
		stationCode = new string(sCode);
	}
	PhoneNumber(const string aCode, const string oCode, const string sCode){
		areaCode = new string(aCode);
		officeCode = new string(oCode);
		stationCode = new string(sCode);
	}
	PhoneNumber(int aCode, int oCode, int sCode){
		areaCode = new string();
		std::stringstream o1;
		o1 << aCode;
		*areaCode = o1.str();
		officeCode = new string();
		std::stringstream o2;
		o2 << oCode;
		*officeCode = o2.str();
		stationCode = new string();
		std::stringstream o3;
		o3 << sCode;
		*stationCode = o3.str();
	}
	PhoneNumber(const PhoneNumber & aNumber){
		areaCode = new string(*(aNumber.areaCode));
		officeCode = new string(*(aNumber.officeCode));
		stationCode = new string(*(aNumber.stationCode));
	}
	PhoneNumber & operator=(const PhoneNumber & aNumber){
		if(this != &aNumber){
			areaCode = aNumber.areaCode;
			officeCode = aNumber.officeCode;
			stationCode = aNumber.stationCode;
		}
		return *this;
	}
	bool operator==(PhoneNumber aNumber){
		if((*areaCode == *(aNumber.areaCode)) && (*officeCode == *(aNumber.officeCode)) && (*stationCode == *(aNumber.stationCode)))
			return true;
		else
			return false;
	}
	~PhoneNumber(){
		delete areaCode;
		delete officeCode;
		delete stationCode;
	}
	void printOn(ostream & ostr) const {
		ostr << "(" << *areaCode << ") " << *officeCode << "-" << *stationCode;
	}

private:
	string * areaCode;
	string * officeCode;
	string * stationCode;

};

ostream & operator<<(ostream & ostr, const PhoneNumber & aNumber) {
	aNumber.printOn(ostr);
	return ostr;
}

#endif