コード例 #1
0
ファイル: Elevator.php プロジェクト: rastaturin/Elevator
 protected function processRequest()
 {
     if (is_null($this->request)) {
         $this->request = $this->getNextRequest();
     }
     if (!is_null($this->request)) {
         if ($this->atFloor($this->request->getFloor())) {
             $this->goingTarget = true;
             $this->go($this->request->getTarget());
         } elseif ($this->goingTarget) {
             if ($this->atFloor($this->request->getTarget())) {
                 $this->stop();
                 $this->request = null;
                 $this->goingTarget = false;
             }
         } else {
             $this->goingTarget = false;
             $this->go($this->request->getFloor());
         }
     }
 }
コード例 #2
0
ファイル: System.php プロジェクト: rastaturin/Elevator
 /**
  * @param Request $request
  * @return Elevator
  */
 protected function pickAnElevator(Request $request)
 {
     return $this->getElevatorAtFloor($request->getFloor()) ?: ($this->getElevatorGoingToFloor($request->getFloor()) ?: $this->getStandingElevator());
 }