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 constructorand displayObject() method for this derived class.
Define another derived class WaterVehicle that also inherits from the Vehicleclass and contains private property: boatCapacity. You may need to override theconstructor 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:
|
IMPORTANT: PLEASE MAKE SURE THAT YOU HAD TESTED YOUR CODE BEFORE POSTING.
YOU CAN USE < www.phptester.net > TO RUN YOUR CODE.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started