Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Car {
- public $colour;
- public $speed;
- public $vechileName;
- public $milage;
- public $price;
- public $totalPrice;
- public function __construct($colour , $speed , $vechileName,$milage, $price){
- $this->colour = $colour;
- $this->speed = $speed;
- $this->vechileName = $vechileName;
- $this->milage = $milage;
- $this->price =$price;
- }
- public function checkColour(){
- if($this->colour == "red"){
- echo " owow";
- }
- else if($this->colour == "yellow") {
- echo " joss";
- }
- else{
- echo "not good";
- }
- }
- public function checkMilage() {
- if($this->vechileName == "lamborgini" && $this->milage > 40){
- echo "this must not be lamborgini";
- }
- else {
- echo "this could be any car";
- }
- }
- public function totalCost(){
- $this->totalPrice = $this->price*0.15+$this->price*0.05;
- echo $this->totalPrice;
- }
- }
- $lamborgini = new Car("red",243,"lamborgini",40,1235425);
- $lamborgini->checkMilage();
- $lamborgini->totalCost();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement