<?php
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.33.0.6934.a386b0a58 modeling language!*/
class Student
{
//------------------------
// MEMBER VARIABLES
//------------------------
//Student Attributes
private $number;
//Student Associations
private $mentors;
//Helper Variables
private $canSetMentors;
//------------------------
// CONSTRUCTOR
//------------------------
public function __construct($aNumber, $allMentors)
{
$this->number = $aNumber;
$this->canSetMentors = true;
$this->mentors = array();
$didAddMentors = $this->setMentors($allMentors);
if (!$didAddMentors)
{
throw new Exception("Unable to create Student, must have at least 1 mentors. See http://manual.umple.org?RE002ViolationofAssociationMultiplicity.html");
}
}
//------------------------
// INTERFACE
//------------------------
public function getNumber()
{
return $this->number;
}
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 1;
}
private function setMentors($newMentors)
{
$wasSet = false;
if (!$this->canSetMentors) { return false; }
$this->canSetMentors = false;
$verifiedMentors = array();
foreach ($newMentors as $aMentor)
{
if (array_search($aMentor,$verifiedMentors) !== false)
{
continue;
}
$verifiedMentors[] = $aMentor;
}
if (count($verifiedMentors) != count($newMentors) || count($verifiedMentors) < self::minimumNumberOfMentors())
{
return $wasSet;
}
$this->mentors = $verifiedMentors;
$wasSet = true;
return $wasSet;
}
public function equals($compareTo)
{
return $this == $compareTo;
}
public function delete()
{}
}
?>
<?php
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.33.0.6934.a386b0a58 modeling language!*/
class Mentor
{
//------------------------
// MEMBER VARIABLES
//------------------------
//Mentor Attributes
private $name;
//------------------------
// CONSTRUCTOR
//------------------------
public function __construct($aName)
{
$this->name = $aName;
}
//------------------------
// INTERFACE
//------------------------
public function getName()
{
return $this->name;
}
public function equals($compareTo)
{
return $this == $compareTo;
}
public function delete()
{}
}
?>