<?php

class Delivery {
  var $status, $pizzaOrder, $deliveryEstimate;

  function Delivery($pizzaOrder) {
    $this->pizzaOrder = $pizzaOrder;
    $this->status = "Otrzymano zamówienie";
  }

  function deliver() {
    if ($this->pizzaOrder->getStatus() == "Gotowa do dostarczenia") {
      srand((double)microtime() * 1000000);
      $this->deliveryEstimate = rand(2, 10);
      $this->status = "Dostarczanie pizzy";
      for ($i = 0; $i<$deliveryEstimate; $i++) {
        // dostarczanie pizzy
      }
      $status = "Pizza dostarczona.";
    } else {
      $this->pizzaOrder->prepOrder();
      $this->deliver();
    }
  }

  function getStatus() {
    return $this->status;
  }

  function getDeliveryEstimate() {
    return $this->deliveryEstimate;
  }
}

?>