//**************************************************************
//
// CS 240C :Spring 2003 Ohio University Travis Dillon
// Project 2 :Emergency Room Triage
// file :room.cc
// started :04-21-03
//
//**************************************************************
#include "room.h"
Room::Room()
{ //room is initially empty and busy for no time
busy = false;
time_left = 0;
}
Room::Room(Time the_time)
{ //initialize the time a patient will be in here
time_left = the_time;
busy = true;
}
bool Room::is_empty()
{ //return true if the room is not occupied
return !busy;
}
Room Room::operator --(int)
{ //takes a second off of the time the room is busy for
//also if time_left becomes 0 then the room is not busy
time_left = time_left -1;
if(time_left <= 0)
{
time_left = 0;
busy = false;
}
return *this;
}
Room Room::operator --()
{ //same as above
time_left = time_left -1;
if(time_left <= 0)
{
time_left = 0;
busy = false;
}
return *this;
}
void Room::show_time_left()
{
cout << time_left;
}
void Room::set_time_left()
{ //set the time busy randomly to 5 to 20 minutes
time_left = (60 * ((rand() % 21) + 5));
busy = true;
}