Using Inheritance To Efficiently Represent Various Vehicle Types

<?
class Vehicle {
     var $model;
     var $current_speed;     function setSpeed($mph) {
          $this->current_speed = $mph;
     }     function getSpeed() {
          return $this->current_speed;
     }
}class Auto extends Vehicle {
    var $fuel_type;    function setFuelType($fuel) {
          $this->fuel_type = $fuel;
    }     function getFuelType() {
          return $this->fuel_type;
     }}class Airplane extends Vehicle {
     var $wingspan;     function setWingSpan($wingspan) {
          $this->wingspan = $wingspan;
     }     function getWingSpan() {
          return $this->wingspan;
     }
}
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.