Advertisement
Guest User

Class

a guest
May 26th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.06 KB | None | 0 0
  1. class Car {
  2.   public $colour;
  3.   public $speed;
  4.   public $vechileName;
  5.   public $milage;
  6.   public $price;
  7.   public $totalPrice;
  8.  
  9.   public function __construct($colour , $speed , $vechileName,$milage, $price){
  10.     $this->colour = $colour;
  11.     $this->speed = $speed;
  12.     $this->vechileName = $vechileName;
  13.     $this->milage = $milage;
  14.     $this->price =$price;
  15.   }
  16.   public function checkColour(){
  17.     if($this->colour == "red"){
  18.       echo " owow";
  19.     }
  20.     else if($this->colour == "yellow") {
  21.       echo " joss";
  22.     }
  23.     else{
  24.       echo "not good";
  25.     }
  26.   }
  27.  
  28.     public function checkMilage() {
  29.       if($this->vechileName == "lamborgini" && $this->milage > 40){
  30.         echo "this must not be lamborgini";
  31.       }
  32.       else {
  33.         echo "this could be any car";
  34.       }
  35.     }
  36.     public function totalCost(){
  37.       $this->totalPrice = $this->price*0.15+$this->price*0.05;
  38.       echo $this->totalPrice;
  39.     }
  40.   }
  41.  
  42.  
  43.  
  44. $lamborgini = new Car("red",243,"lamborgini",40,1235425);
  45.  
  46. $lamborgini->checkMilage();
  47. $lamborgini->totalCost();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement