<?php
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE @UMPLE_VERSION@ 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 https://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);
    }
  }

}
?>