Question: Object.php Create a PHP script that will perform the following tasks. Define a class Vehicle which has protected properties: make, model, year, price. Create a
Object.php
Create a PHP script that will perform the following tasks.
Define a class Vehicle which has protected properties: make, model, year, price. Create a constructor method that takes in make, model, year, and price. Implement a public method displayObject() to display the properties of each object instance.
Define a derived class LandVehicle that inherits from the Vehicle class and contains a private property: maxSpeed. You may need to override the constructor and displayObject() method for this derived class.
Define another derived class WaterVehicle that also inherits from the Vehicle class and contains private property: boatCapacity. You may need to override the constructor and displayObject() method for this derived class.
Instantiate (Create) at least three objects of LandVehicle and display the properties of each object instance. Sample output is as follows:
|
Instantiate (Create) at least three objects of WaterVehicle and display the properties of each object instance. Sample output is as follows:
|
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
