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

class MySubordinate
{

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

  //MySubordinate Attributes
  private $number;

  //MySubordinate Associations
  private $myDriver;

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

  public function __construct($aNumber, $aMyDriver)
  {
    $this->number = $aNumber;
    $didAddMyDriver = $this->setMyDriver($aMyDriver);
    if (!$didAddMyDriver)
    {
      throw new Exception("Unable to create mySubordinate due to myDriver. See http://manual.umple.org?RE002ViolationofAssociationMultiplicity.html");
    }
  }

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

  public function setNumber($aNumber)
  {
    $wasSet = false;
    $this->number = $aNumber;
    $wasSet = true;
    return $wasSet;
  }

  public function getNumber()
  {
    return $this->number;
  }

  public function getMyDriver()
  {
    return $this->myDriver;
  }

  public function setMyDriver($aNewMyDriver)
  {
    $wasSet = false;
    if ($aNewMyDriver == null)
    {
      //Unable to setMyDriver to null, as mySubordinate must always be associated to a myDriver
      return $wasSet;
    }
    
    $existingMySubordinate = $aNewMyDriver->getMySubordinate();
    if ($existingMySubordinate != null && $this != $existingMySubordinate)
    {
      //Unable to setMyDriver, the current myDriver already has a mySubordinate, which would be orphaned if it were re-assigned
      return $wasSet;
    }
    
    $anOldMyDriver = $this->myDriver;
    $this->myDriver = $aNewMyDriver;
    $this->myDriver->setMySubordinate($this);
    
    if ($anOldMyDriver != null)
    {
      $anOldMyDriver->setMySubordinate(null);
    }
    $wasSet = true;
    return $wasSet;
  }

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

  public function delete()
  {
    $existingMyDriver = $this->myDriver;
    $this->myDriver = null;
    if ($existingMyDriver != null)
    {
      $existingMyDriver->setMySubordinate(null);
    }
  }

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

class MyDriver
{

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

  //MyDriver Attributes
  private $name;

  //MyDriver Associations
  public $mySubordinate; //until PHP 5.3 (setAccessible)

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

  public function __construct($aName)
  {
    $this->name = $aName;
  }

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

  public function setName($aName)
  {
    $wasSet = false;
    $this->name = $aName;
    $wasSet = true;
    return $wasSet;
  }

  public function getName()
  {
    return $this->name;
  }

  public function getMySubordinate()
  {
    return $this->mySubordinate;
  }

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

  public function setMySubordinate($aNewMySubordinate)
  {
    $wasSet = false;
    if ($this->mySubordinate != null && $this->mySubordinate != $aNewMySubordinate && $this == $this->mySubordinate->getMyDriver())
    {
      //Unable to setMySubordinate, as existing mySubordinate would become an orphan
      return $wasSet;
    }
    
    $this->mySubordinate = $aNewMySubordinate;
    $anOldMyDriver = $aNewMySubordinate != null ? $aNewMySubordinate->getMyDriver() : null;
    
    if ($this != $anOldMyDriver)
    {
      if ($anOldMyDriver != null)
      {
        $anOldMyDriver->mySubordinate = null;
      }
      if ($this->mySubordinate != null)
      {
        $this->mySubordinate->setMyDriver($this);
      }
    }
    $wasSet = true;
    return $wasSet;
  }

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

  public function delete()
  {
    $existingMySubordinate = $this->mySubordinate;
    $this->mySubordinate = null;
    if ($existingMySubordinate != null)
    {
      $existingMySubordinate->delete();
    }
  }

}
?>