//=============================================================================

#include <iostream>
#include "person.h"
using namespace std;

//-----------------------------------------------------------------------------

bool person::meet(person& p1, person& p2)
{
   if (p1.is_unknowing() && p2.is_unknowing())
   {
      //p1.state_ = state::unknowing;
      //p2.state_ = state::unknowing;
      return false;
   }
   if (p1.is_unknowing() && p2.is_telling())
   {
      p1.state_ = state::telling;
      //p2.state_ = state::telling;
      return true;
   }
   if (p1.is_unknowing() && p2.is_closemouthed())
   {
      //p1.state_ = state::unknowing;
      //p2.state_ = state::closemouthed;
      return false;
   }
   if (p1.is_telling() && p2.is_unknowing())
   {
      //p1.state_ = state::telling;
      p2.state_ = state::telling;
      return true;
   }
   if (p1.is_telling() && p2.is_telling())
   {
      p1.state_ = state::closemouthed;
      p2.state_ = state::closemouthed;
      return true;
   }
   if (p1.is_telling() && p2.is_closemouthed())
   {
      p1.state_ = state::closemouthed;
      //p2.state_ = state::closemouthed;
      return true;
   }
   if (p1.is_closemouthed() && p2.is_unknowing())
   {
      //p1.state_ = state::closemouthed;
      //p2.state_ = state::unknowing;
      return false;
   }
   if (p1.is_closemouthed() && p2.is_telling())
   {
      //p1.state_ = state::closemouthed;
      p2.state_ = state::closemouthed;
      return true;
   }
   //p1.state_ = state::closemouthed;
   //p2.state_ = state::closemouthed;
   return false;
}

//-----------------------------------------------------------------------------

void person::print() const
{
   switch (state_)
   {
   case state::unknowing:
      cout << '_';
      break;
   case state::telling:
      cout << '|';
      break;
   case state::closemouthed:
      cout << '*';
      break;
   }
}
