예제 #1
0
파일: Persons.php 프로젝트: Just-Man/PHP
 /**
  * @param mixed $car
  */
 public function buyCar(Cars $car)
 {
     $price = $car->getPrice();
     if ($this->money >= $price) {
         $this->car = $car;
         $this->money -= $price;
         $car->setOwner($this);
         echo 'You heve a new car', PHP_EOL;
         return true;
     } else {
         echo 'You don\'t have enough money';
         return false;
     }
 }
예제 #2
0
파일: Cars.php 프로젝트: Just-Man/PHP
 public function isMoreExpensive(Cars $car)
 {
     if ($this->price < $car->getPrice()) {
         return 'Other car is more Expensive';
     } else {
         return 'Your car is more Expensive';
     }
 }