All pastes #673485 Raw Edit

Untitled

public cpp v1 · immutable
#673485 ·published 2007-08-28 13:31 UTC
rendered paste body
#define CUST_NO 10#define EMPL_NO 1using namespace std;//Typos/kathgoria provlimatosenum errortype { NOERROR = 0, PSTN = 1, ISDN = 2, ADSL = 3, INTERNET = 4};typedef struct{	int	id;	string 	onoma;	unsigned long long tel;	errortype category;	bool	condition;}record;class pelaths{public:	//Constructors/Destructor	pelaths():haveerror((errortype)0), reported(0), found(NULL){}	pelaths(string on, unsigned long long til):haveerror((errortype)0), reported(0), onoma(on), phone_num(til),found(NULL){}	~pelaths();	//public methodoi	void	act();		//Kanei ton pelati na drasei, elegxei an exei provlima	string	get_onoma(){return onoma;}		//epistrefei to onoma tou pelati	errortype get_error(){return haveerror;}	//epistrefei ton typo toy provlimatos	//public idiotites	unsigned long long phone_num;	//arithmos tilefonou pelath		errortype haveerror;	//typos problimatos (0=NOERROR)private://private methodoi	bool 	findhelp(); 	//psaxnei gia diathesimo upalilo kai ton kalei	void 	talk(); 	//kanei tin sinomilia	//private idiotites	bool	reported;	//an exei dilothei i vlavi	string 	onoma;		//onoma pelath	ypalilos *found;	//pointer ston upalilo pou vrike};//Ylopoiisi methodwnvoid	pelaths::act(){	if (haveerror == 0) return; //No error, no actions	//Yparxei provlima	//Psaxnoume upalilo gia voithia kai ton kaloume	if (findhelp()) //An vrethei diathesimos ipalilos	{		talk(); //ton kaloume	}//an den vrethike, den kanoume kati	found == NULL;	return;}bool	pelaths::findhelp(){	ypalilos *tmp = (ypalilos*)adressbook(1); //Zitame to array twn ypalilwn	for (int i = 0; i < EMPL_NO; i++)	{		if (tmp[i].getcond() == 0) 		{			found == &tmp[i]; //Diefthinsi tou upalilou pou vrethike diathesimos			return 1;		}	}	return 0;}void pelaths::talk(){	bool tmp;	tmp = found->answer(this, reported);	if (tmp) //if the answer is yes, then we check what we asked	{		if (reported) //if it was reported, yes means its now fixed		{			haveerror = (errortype)0;			reported = 0;			return;		}		else //it was not reported, yes means it is now		{			reported = 1;			return;		}	} //If tmp == 0 then either didnt answer, either nothing changed, both effect nothing	return;}