cleaner.cpp
/*
* Nathan Eloe 4/24/2013
* cleaner.cpp
* Implementation of the cleaner class
*/
#include "house.h"
#include "cleaner.h"
void Cleaner::calc_stress(const House & house)
{
int trash = 0, fam = 0;
for (int i=0; i<house.size(); i++)
{
for (int j=0; j<house.size(); j++)
{
if (house.cell(i,j)!=' ' && house.cell(i,j)!=m_name[0])
house.cell(i,j)=='t' ? trash++ : fam++;
}
}
m_stress = static_cast<int>((100.0 * trash) / (house.size() *
house.size()))+ 2 * fam;
m_stress = m_stress > 100 ? 100 : m_stress;
m_stress = m_stress < 0 ? 0 : m_stress;
return;
}
ostream & operator << (ostream & o, const Cleaner & c)
{
o << c.m_name << " is at " << c.m_loc << " stressed at level "
<< c.m_stress;
return o;
}