<?php
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

class Student
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Student Associations
  private $mentors;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public function __construct()
  {
    $this->mentors = array();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public function getMentor_index($index)
  {
    $aMentor = $this->mentors[$index];
    return $aMentor;
  }

  public function getMentors()
  {
    $newMentors = $this->mentors;
    return $newMentors;
  }

  public function numberOfMentors()
  {
    $number = count($this->mentors);
    return $number;
  }

  public function hasMentors()
  {
    $has = $this->numberOfMentors() > 0;
    return $has;
  }

  public function indexOfMentor($aMentor)
  {
    $wasFound = false;
    $index = 0;
    foreach($this->mentors as $mentor)
    {
      if ($mentor->equals($aMentor))
      {
        $wasFound = true;
        break;
      }
      $index += 1;
    }
    $index = $wasFound ? $index : -1;
    return $index;
  }

  public static function minimumNumberOfMentors()
  {
    return 0;
  }

  public function addMentor($aMentor)
  {
    $wasAdded = false;
    if ($this->indexOfMentor($aMentor) !== -1) { return false; }
    $this->mentors[] = $aMentor;
    if ($aMentor->indexOfStudent($this) != -1)
    {
      $wasAdded = true;
    }
    else
    {
      $wasAdded = $aMentor->addStudent($this);
      if (!$wasAdded)
      {
        array_pop($this->mentors);
      }
    }
    return $wasAdded;
  }

  public function removeMentor($aMentor)
  {
    $wasRemoved = false;
    if ($this->indexOfMentor($aMentor) == -1)
    {
      return $wasRemoved;
    }

    $oldIndex = $this->indexOfMentor($aMentor);
    unset($this->mentors[$oldIndex]);
    if ($aMentor->indexOfStudent($this) == -1)
    {
      $wasRemoved = true;
    }
    else
    {
      $wasRemoved = $aMentor->removeStudent($this);
      if (!$wasRemoved)
      {
        $this->mentors[$oldIndex] = $aMentor;
        ksort($this->mentors);
      }
    }
    $this->mentors = array_values($this->mentors);
    return $wasRemoved;
  }

  public function addMentorAt($aMentor, $index)
  {  
    $wasAdded = false;
    if($this->addMentor($aMentor))
    {
      if($index < 0 ) { $index = 0; }
      if($index > $this->numberOfMentors()) { $index = $this->numberOfMentors() - 1; }
      array_splice($this->mentors, $this->indexOfMentor($aMentor), 1);
      array_splice($this->mentors, $index, 0, array($aMentor));
      $wasAdded = true;
    }
    return $wasAdded;
  }

  public function addOrMoveMentorAt($aMentor, $index)
  {
    $wasAdded = false;
    if($this->indexOfMentor($aMentor) !== -1)
    {
      if($index < 0 ) { $index = 0; }
      if($index > $this->numberOfMentors()) { $index = $this->numberOfMentors() - 1; }
      array_splice($this->mentors, $this->indexOfMentor($aMentor), 1);
      array_splice($this->mentors, $index, 0, array($aMentor));
      $wasAdded = true;
    } 
    else 
    {
      $wasAdded = $this->addMentorAt($aMentor, $index);
    }
    return $wasAdded;
  }

  public function equals($compareTo)
  {
    return $this == $compareTo;
  }

  public function delete()
  {
    $copyOfMentors = $this->mentors;
    $this->mentors = array();
    foreach ($copyOfMentors as $aMentor)
    {
      $aMentor->removeStudent($this);
    }
  }

}
?>
<?php
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

class Student
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Student Associations
  private $mentors;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public function __construct()
  {
    $this->mentors = array();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public function getMentor_index($index)
  {
    $aMentor = $this->mentors[$index];
    return $aMentor;
  }

  public function getMentors()
  {
    $newMentors = $this->mentors;
    return $newMentors;
  }

  public function numberOfMentors()
  {
    $number = count($this->mentors);
    return $number;
  }

  public function hasMentors()
  {
    $has = $this->numberOfMentors() > 0;
    return $has;
  }

  public function indexOfMentor($aMentor)
  {
    $wasFound = false;
    $index = 0;
    foreach($this->mentors as $mentor)
    {
      if ($mentor->equals($aMentor))
      {
        $wasFound = true;
        break;
      }
      $index += 1;
    }
    $index = $wasFound ? $index : -1;
    return $index;
  }

  public static function minimumNumberOfMentors()
  {
    return 0;
  }

  public function addMentor($aMentor)
  {
    $wasAdded = false;
    if ($this->indexOfMentor($aMentor) !== -1) { return false; }
    $this->mentors[] = $aMentor;
    if ($aMentor->indexOfStudent($this) != -1)
    {
      $wasAdded = true;
    }
    else
    {
      $wasAdded = $aMentor->addStudent($this);
      if (!$wasAdded)
      {
        array_pop($this->mentors);
      }
    }
    return $wasAdded;
  }

  public function removeMentor($aMentor)
  {
    $wasRemoved = false;
    if ($this->indexOfMentor($aMentor) == -1)
    {
      return $wasRemoved;
    }

    $oldIndex = $this->indexOfMentor($aMentor);
    unset($this->mentors[$oldIndex]);
    if ($aMentor->indexOfStudent($this) == -1)
    {
      $wasRemoved = true;
    }
    else
    {
      $wasRemoved = $aMentor->removeStudent($this);
      if (!$wasRemoved)
      {
        $this->mentors[$oldIndex] = $aMentor;
        ksort($this->mentors);
      }
    }
    $this->mentors = array_values($this->mentors);
    return $wasRemoved;
  }

  public function addMentorAt($aMentor, $index)
  {  
    $wasAdded = false;
    if($this->addMentor($aMentor))
    {
      if($index < 0 ) { $index = 0; }
      if($index > $this->numberOfMentors()) { $index = $this->numberOfMentors() - 1; }
      array_splice($this->mentors, $this->indexOfMentor($aMentor), 1);
      array_splice($this->mentors, $index, 0, array($aMentor));
      $wasAdded = true;
    }
    return $wasAdded;
  }

  public function addOrMoveMentorAt($aMentor, $index)
  {
    $wasAdded = false;
    if($this->indexOfMentor($aMentor) !== -1)
    {
      if($index < 0 ) { $index = 0; }
      if($index > $this->numberOfMentors()) { $index = $this->numberOfMentors() - 1; }
      array_splice($this->mentors, $this->indexOfMentor($aMentor), 1);
      array_splice($this->mentors, $index, 0, array($aMentor));
      $wasAdded = true;
    } 
    else 
    {
      $wasAdded = $this->addMentorAt($aMentor, $index);
    }
    return $wasAdded;
  }

  public function equals($compareTo)
  {
    return $this == $compareTo;
  }

  public function delete()
  {
    $copyOfMentors = $this->mentors;
    $this->mentors = array();
    foreach ($copyOfMentors as $aMentor)
    {
      $aMentor->removeStudent($this);
    }
  }

}
?>
<?php
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

class Student
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Student Attributes
  private $intId;
  private $doubleId;
  private $booleanId;
  private $stringId;
  private $stringListIds;

  //Helper Variables
  private $cachedHashCode;
  private $canSetIntId;
  private $canSetDoubleId;
  private $canSetBooleanId;
  private $canSetStringId;
  private $canSetStringListIds;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public function __construct($aIntId, $aDoubleId, $aBooleanId, $aStringId)
  {
    $this->cachedHashCode = -1;
    $this->canSetIntId = true;
    $this->canSetDoubleId = true;
    $this->canSetBooleanId = true;
    $this->canSetStringId = true;
    $this->canSetStringListIds = true;
    $this->intId = $aIntId;
    $this->doubleId = $aDoubleId;
    $this->booleanId = $aBooleanId;
    $this->stringId = $aStringId;
    $this->stringListIds = array();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public function setIntId($aIntId)
  {
    $wasSet = false;
    if (!$this->canSetIntId) { return false; }
    $this->intId = $aIntId;
    $wasSet = true;
    return $wasSet;
  }

  public function setDoubleId($aDoubleId)
  {
    $wasSet = false;
    if (!$this->canSetDoubleId) { return false; }
    $this->doubleId = $aDoubleId;
    $wasSet = true;
    return $wasSet;
  }

  public function setBooleanId($aBooleanId)
  {
    $wasSet = false;
    if (!$this->canSetBooleanId) { return false; }
    $this->booleanId = $aBooleanId;
    $wasSet = true;
    return $wasSet;
  }

  public function setStringId($aStringId)
  {
    $wasSet = false;
    if (!$this->canSetStringId) { return false; }
    $this->stringId = $aStringId;
    $wasSet = true;
    return $wasSet;
  }

  public function addStringListId($aStringListId)
  {
    $wasAdded = false;
    if (!$this->canSetStringListIds) { return false; }
    $this->stringListIds[] = $aStringListId;
    $wasAdded = true;
    return $wasAdded;
  }

  public function removeStringListId($aStringListId)
  {
    $wasRemoved = false;
    if (!$this->canSetStringListIds) { return false; }
    unset($this->stringListIds[$this->indexOfStringListId($aStringListId)]);
    $this->stringListIds = array_values($this->stringListIds);
    $wasRemoved = true;
    return $wasRemoved;
  }

  public function getIntId()
  {
    return $this->intId;
  }

  public function getDoubleId()
  {
    return $this->doubleId;
  }

  public function getBooleanId()
  {
    return $this->booleanId;
  }

  public function getStringId()
  {
    return $this->stringId;
  }

  public function getStringListId($index)
  {
    $aStringListId = $this->stringListIds[$index];
    return $aStringListId;
  }

  public function getStringListIds()
  {
    $newStringListIds = $this->stringListIds;
    return $newStringListIds;
  }

  public function numberOfStringListIds()
  {
    $number = count($this->stringListIds);
    return $number;
  }

  public function hasStringListIds()
  {
    $has = stringListIds.size() > 0;
    return $has;
  }

  public function indexOfStringListId($aStringListId)
  {
    $rawAnswer = array_search($aStringListId,$this->stringListIds);
    $index = $rawAnswer == null && $rawAnswer !== 0 ? -1 : $rawAnswer;
    return $index;
  }

  public function isBooleanId()
  {
    return $this->booleanId;
  }

  public function equals($compareTo)
  {
    if ($compareTo == null) { return false; }
    if (get_class($this) != get_class($compareTo)) { return false; }

    if ($this->intId != $compareTo->intId)
    {
      return false;
    }

    if ($this->doubleId != $compareTo->doubleId)
    {
      return false;
    }

    if ($this->booleanId != $compareTo->booleanId)
    {
      return false;
    }

    if ($this->stringId != $compareTo->stringId)
    {
      return false;
    }

    if ($this->stringListIds != $compareTo->stringListIds)
    {
      return false;
    }

    return true;
  }

  public function hashCode()
  {
    if ($this->cachedHashCode != -1)
    {
      return $this->cachedHashCode;
    }
    $this->cachedHashCode = 17;
    $this->cachedHashCode = $this->cachedHashCode * 23 + $this->intId;

    $this->cachedHashCode = $this->cachedHashCode * 23 + $this->doubleId;

    $this->cachedHashCode = $this->cachedHashCode * 23 + ($this->booleanId ? 1 : 0);

    if ($this->stringId != null)
    {
      $this->cachedHashCode = $this->cachedHashCode * 23 + spl_object_hash($this->stringId);
    }
    else
    {
      $this->cachedHashCode = $this->cachedHashCode * 23;
    }

    if ($this->stringListIds != null)
    {
      $this->cachedHashCode = $this->cachedHashCode * 23 + spl_object_hash($this->stringListIds);
    }
    else
    {
      $this->cachedHashCode = $this->cachedHashCode * 23;
    }

    $this->canSetIntId = false;
    $this->canSetDoubleId = false;
    $this->canSetBooleanId = false;
    $this->canSetStringId = false;
    $this->canSetStringListIds = false;
    return $this->cachedHashCode;
  }

  public function delete()
  {}

}
?>
<?php
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

class Student
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Student Attributes
  private $intId;
  private $doubleId;
  private $booleanId;
  private $stringId;

  //Helper Variables
  private $cachedHashCode;
  private $canSetIntId;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public function __construct($aDoubleId, $aBooleanId, $aStringId)
  {
    $this->cachedHashCode = -1;
    $this->canSetIntId = true;
    $this->doubleId = $aDoubleId;
    $this->booleanId = $aBooleanId;
    $this->stringId = $aStringId;
  }

  //------------------------
  // INTERFACE
  //------------------------

  public function setIntId($aIntId)
  {
    $wasSet = false;
    if (!$this->canSetIntId) { return false; }
    $this->canSetIntId = false;
    $this->intId = $aIntId;
    $wasSet = true;
    return $wasSet;
  }

  public function getIntId()
  {
    return $this->intId;
  }

  public function getDoubleId()
  {
    return $this->doubleId;
  }

  public function getBooleanId()
  {
    return $this->booleanId;
  }

  public function getStringId()
  {
    return $this->stringId;
  }

  public function isBooleanId()
  {
    return $this->booleanId;
  }

  public function equals($compareTo)
  {
    if ($compareTo == null) { return false; }
    if (get_class($this) != get_class($compareTo)) { return false; }

    if ($this->intId != $compareTo->intId)
    {
      return false;
    }

    if ($this->doubleId != $compareTo->doubleId)
    {
      return false;
    }

    if ($this->booleanId != $compareTo->booleanId)
    {
      return false;
    }

    if ($this->stringId != $compareTo->stringId)
    {
      return false;
    }

    return true;
  }

  public function hashCode()
  {
    if ($this->cachedHashCode != -1)
    {
      return $this->cachedHashCode;
    }
    $this->cachedHashCode = 17;
    $this->cachedHashCode = $this->cachedHashCode * 23 + $this->intId;

    $this->cachedHashCode = $this->cachedHashCode * 23 + $this->doubleId;

    $this->cachedHashCode = $this->cachedHashCode * 23 + ($this->booleanId ? 1 : 0);

    if ($this->stringId != null)
    {
      $this->cachedHashCode = $this->cachedHashCode * 23 + spl_object_hash($this->stringId);
    }
    else
    {
      $this->cachedHashCode = $this->cachedHashCode * 23;
    }

    $this->canSetIntId = false;
    $this->canSetDoubleId = false;
    $this->canSetBooleanId = false;
    $this->canSetStringId = false;
    return $this->cachedHashCode;
  }

  public function delete()
  {}

}
?>
<?php
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

class Mentor
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Mentor Associations
  private $main;
  private $secondaries;

  //Helper Variables
  private $cachedHashCode;
  private $canSetMain;
  private $canSetSecondaries;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public function __construct()
  {
    $this->cachedHashCode = -1;
    $this->canSetMain = true;
    $this->canSetSecondaries = true;
    $this->secondaries = array();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public function getMain()
  {
    return $this->main;
  }

  public function hasMain()
  {
    $has = $this->main != null;
    return $has;
  }

  public function getSecondary_index($index)
  {
    $aSecondary = $this->secondaries[$index];
    return $aSecondary;
  }

  public function getSecondaries()
  {
    $newSecondaries = $this->secondaries;
    return $newSecondaries;
  }

  public function numberOfSecondaries()
  {
    $number = count($this->secondaries);
    return $number;
  }

  public function hasSecondaries()
  {
    $has = $this->numberOfSecondaries() > 0;
    return $has;
  }

  public function indexOfSecondary($aSecondary)
  {
    $wasFound = false;
    $index = 0;
    foreach($this->secondaries as $secondary)
    {
      if ($secondary->equals($aSecondary))
      {
        $wasFound = true;
        break;
      }
      $index += 1;
    }
    $index = $wasFound ? $index : -1;
    return $index;
  }

  public function setMain($aNewMain)
  {
    $wasSet = false;
    if (!$this->canSetMain) { return false; }
    if ($aNewMain == null)
    {
      $existingMain = $this->main;
      $this->main = null;
      
      if ($existingMain != null && $existingMain->getMentorMain() != null)
      {
        $existingMain->setMentorMain(null);
      }
      $wasSet = true;
      return $wasSet;
    }
    
    $currentMain = $this->getMain();
    if ($currentMain != null && $currentMain != $aNewMain)
    {
      $currentMain->setMentorMain(null);
    }
    
    $this->main = $aNewMain;
    $existingMentorMain = $aNewMain->getMentorMain();
    
    if ($this != $existingMentorMain)
    {
      $aNewMain->setMentorMain($this);
    }
    $wasSet = true;
    return $wasSet;
  }

  public static function minimumNumberOfSecondaries()
  {
    return 0;
  }

  public function addSecondary($aSecondary)
  {
    $wasAdded = false;
    if (!$this->canSetSecondaries) { return false; }
    if ($this->indexOfSecondary($aSecondary) !== -1) { return false; }
    $existingMentorSecondary = $aSecondary->getMentorSecondary();
    if ($existingMentorSecondary == null)
    {
      $aSecondary->setMentorSecondary($this);
    }
    elseif ($this !== $existingMentorSecondary)
    {
      $existingMentorSecondary->removeSecondary($aSecondary);
      $this->addSecondary($aSecondary);
    }
    else
    {
      $this->secondaries[] = $aSecondary;
    }
    $wasAdded = true;
    return $wasAdded;
  }

  public function removeSecondary($aSecondary)
  {
    $wasRemoved = false;
    if (!$this->canSetSecondaries) { return false; }
    if ($this->indexOfSecondary($aSecondary) != -1)
    {
      unset($this->secondaries[$this->indexOfSecondary($aSecondary)]);
      $this->secondaries = array_values($this->secondaries);
      if ($this === $aSecondary->getMentorSecondary())
      {
        $aSecondary->setMentorSecondary(null);
      }
      $wasRemoved = true;
    }
    return $wasRemoved;
  }

  public function addSecondaryAt($aSecondary, $index)
  {  
    $wasAdded = false;
    if($this->addSecondary($aSecondary))
    {
      if($index < 0 ) { $index = 0; }
      if($index > $this->numberOfSecondaries()) { $index = $this->numberOfSecondaries() - 1; }
      array_splice($this->secondaries, $this->indexOfSecondary($aSecondary), 1);
      array_splice($this->secondaries, $index, 0, array($aSecondary));
      $wasAdded = true;
    }
    return $wasAdded;
  }

  public function addOrMoveSecondaryAt($aSecondary, $index)
  {
    $wasAdded = false;
    if($this->indexOfSecondary($aSecondary) !== -1)
    {
      if($index < 0 ) { $index = 0; }
      if($index > $this->numberOfSecondaries()) { $index = $this->numberOfSecondaries() - 1; }
      array_splice($this->secondaries, $this->indexOfSecondary($aSecondary), 1);
      array_splice($this->secondaries, $index, 0, array($aSecondary));
      $wasAdded = true;
    } 
    else 
    {
      $wasAdded = $this->addSecondaryAt($aSecondary, $index);
    }
    return $wasAdded;
  }

  public function equals($compareTo)
  {
    if ($compareTo == null) { return false; }
    if (get_class($this) != get_class($compareTo)) { return false; }

    if ($this->main != $compareTo->main)
    {
      return false;
    }

    if ($this->secondaries != $compareTo->secondaries)
    {
      return false;
    }

    return true;
  }

  public function hashCode()
  {
    if ($this->cachedHashCode != -1)
    {
      return $this->cachedHashCode;
    }
    $this->cachedHashCode = 17;
    if ($this->main != null)
    {
      $this->cachedHashCode = $this->cachedHashCode * 23 + spl_object_hash($this->main);
    }
    else
    {
      $this->cachedHashCode = $this->cachedHashCode * 23;
    }
    if ($this->secondaries != null)
    {
      $this->cachedHashCode = $this->cachedHashCode * 23 + spl_object_hash($this->secondaries);
    }
    else
    {
      $this->cachedHashCode = $this->cachedHashCode * 23;
    }

    $this->canSetMain = false;
    $this->canSetSecondaries = false;
    return $this->cachedHashCode;
  }

  public function delete()
  {
    if ($this->main != null)
    {
      $this->main->setMentorMain(null);
    }
    foreach ($this->secondaries as $aSecondary)
    {
      $aSecondary->setMentorSecondary(null);
    }
  }

}
?>