/*------------------------------------------------------------------------------
Description: button classes for elevator project
Author: Chris Huyler
Language: C++
Name: buttons.h
Date: March 30, 2000
------------------------------------------------------------------------------*/
#include <cstring.h>

class button {
	public:
   		button();
   		void dim();
    	void illuminate();
    	bool get_lit();
    	virtual void press();
      virtual string identify(void);
   protected:
   		Log *ControlLog;
   private:
   		enum light{on,off};
      	light buttonLight;
};
button::button(){
	buttonLight = off;
    ControlLog = Log::Instance();
}

void button::dim(){
	buttonLight = off;
}
void button::illuminate(){
	buttonLight = on;
}
bool button::get_lit(){
	return(buttonLight == on);
}
void button::press(){
	illuminate();
}
string button::identify(void){
	return("button");
}



class ebutton:public button {
	public:
   	ebutton();
      ebutton(int i,int f);
      void press();
      void set_eID(int i);
      void set_floor(int f);
      int get_eID();
      int get_floor();
   	string identify(void);
   private:
   	int eID;
      int floor;
};
ebutton::ebutton(){
	eID = 0;
   floor = 0;
}
void ebutton::press(){
	illuminate();
   ControlLog->Print_ElevatorButtonPress(floor,eID);
}
ebutton::ebutton(int i,int f){
	eID = i;
   floor = f;
}
void ebutton::set_eID(int i){
	eID = i;
}
void ebutton::set_floor(int f){
	floor = f;
}
int ebutton::get_eID(){
	return(eID);
}
int ebutton::get_floor(){
	return(floor);
}
string ebutton::identify(void){
	return("ebutton");
}





class fbutton:public button {
	public:
   	fbutton();
      fbutton(string d, int f);
      void press();
      void set_dir(string d);
      void set_floor(int f);
      string get_dir();
      int get_floor();
   	string identify(void);
   private:
   	enum dir{up,down};
      dir direction;
      int floor;
};
fbutton::fbutton(){
	direction = up;
   floor = 0;
}
fbutton::fbutton(string d,int f){
	set_dir(d);
   floor = f;
}
void fbutton::press(){
	illuminate();
   if(direction == down)
   	ControlLog->Print_FloorButtonPress(floor,"down");
   else
   	ControlLog->Print_FloorButtonPress(floor,"up");
}
void fbutton::set_dir(string d){
	if(d == "up") direction = up;
   if(d == "down") direction = down;
}
void fbutton::set_floor(int f){
	floor = f;
}
string fbutton::get_dir(){
	if(direction == up)
   	return("up");
   else
   	return("down");
}
int fbutton::get_floor(){
	return(floor);
}
string fbutton::identify(void){
	return("fbutton");
}
