#include <cstdlib>
#include <cassret>
#include "planes.h"
#include "randgen.h"

using namespace std;
namespace CS256_sim
{


//class plane
plane::plane()
{
	entry_time=666;
	legnth = 5;
	service = NONE;
	fuel_rem = 50;
}
plane::plane(svc_type torl, time long, time fuel)
{
	entry_time=666;
	legnth = long;
	fuel_rem=fuel;
	service = NONE;
}
time plane::get_time()
{
	return entry_time;
}
time plane::get_legnth()
{
	return legnth;
}
void plane::set_time(time enter)
{
	entry_time = enter;
}
svc_type plane::get_svc()
{
	return service;
}



//class strip
strip::strip()
{
	remain = 0;
}
void strip::one_sec()
{
	remain--;
}
bool strip::is_busy()
{
	return(remain!=0);
}
void start(time how_long)
{
	remain=how_long;
}


//class source

source::source(svc_type torl. time minlen, time maxlen,
		time minfuel, time maxfuel, double p_arr);
{
	return;
}
plane soure::query()
{
	time len = randInt(minlen, maxlen);
	time fuel = randInt(minfuel, maxfuel);
	double new = randDbl(0.00, 1);
	if(new<=p_arr)
	return plane(torl, len, fuel);
	else
	return plane(NONE,0,0);
}


//class stats
stats::stats()
{
	crashes = takeoffs = lands = 0;
	total_land = total_off = 0;
}
void stats::update(plane k, time current_time)
{
	if(plane.get_svc() == TAKEOFF)
	{
		takeoffs++
		total_off += current_time - k.get_time();
	}
	
	if(plane.get_svc() == LAND)
	{
		if(k.get_fuel <= 0)
		crashes++;
		else
		{
			lands++;
			total_land += current_time - k.get_time();
		}
	}
}

