/*
  Mens.cpp
  Copyright (c) 2014 Kenneth van Ewijk.  All right reserved.
*/

// include this library's description file
#include "Mens.h"

Mens::Mens(void)
{
  // initialize this instance's variables
  pattern[80][3];
  counter = 0;
}


//Set Heater Properties
void Mens::setPattern(int givenPattern[80][3], int len)
{
  pattern[80][3] = givenPattern[80][3];
}

int Mens::getTimeToEnter(int givenTime){
  int timer = givenTime % 25200;

  int enter = pattern[counter][0];
  int room = pattern[counter][1];
  int leave = pattern[counter][2];

  if(timer > leave){
    counter++;
  }

  int rtn[2] = {enter-timer, room};

  if(rtn[0] < 0 && rtn[1]==0){
    rtn[2] = getTimeToEnter(timer);
  }

  return rtn[2];
}

int Mens::getTimeToLeave(int givenTime){
  int timer = givenTime % 25200;

  int enter = pattern[counter][0];
  int room = pattern[counter][1];
  int leave = pattern[counter][2];

  if(timer > leave){
    counter++;
  }

  int rtn[2] = {leave-timer, room};

  if(rtn[0] < 0 && rtn[1]==0){
    rtn[2] = getTimeToEnter(timer);
  }

  return rtn[2];
}