$car1->set_milage(15); $car1->Display_all(); echo "<br>"; $car2 = new Car(); $car2->set_price(2000); $car2->set_speed(5); $car2->set_fuel(0); $car2->set_milage(105); $car2->Display_all(); echo "<br>"; $car3 = new Car(); $car3->set_price(2000); $car3->set_speed(35); $car3->set_fuel(50); $car3->set_milage(20); $car3->Display_all(); echo "<br>"; $car4 = new Car(); $car4->set_price(2000000); $car4->set_speed(200); $car4->set_fuel(75); $car4->set_milage(30); $car4->Display_all(); echo "<br>"; $car5 = new Car(); $car5->set_price(2000); $car5->set_speed(40); $car5->set_fuel(100); $car5->set_milage(45); $car5->Display_all(); echo "<br>";
$this->mileage = $mileage; if ($price > 10000) { $this->tax = 0.15; } else { $this->tax = 0.12; } } //methods public function Display_all() { echo "Price: {$this->price}\n"; echo "Speed: {$this->speed}\n"; echo "Fuel: {$this->fuel}\n"; echo "Mileage: {$this->mileage}\n"; echo "Tax: {$this->tax}\n\n"; } } $obj1 = new Car(2000, 35, 'Full', 15); // price and max speed. $obj2 = new Car(2000, 5, 'Not Full', 105); $obj3 = new Car(2000, 15, 'Kind of Full', 95); $obj4 = new Car(2000, 25, 'Full', 25); $obj5 = new Car(2000, 45, 'Empty', 25); $obj6 = new Car(20000000, 35, 'Empty', 15); echo $obj1->Display_all(); echo $obj2->Display_all(); echo $obj3->Display_all(); echo $obj4->Display_all(); echo $obj5->Display_all(); echo $obj6->Display_all();