Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Object.php Create a PHP script that will perform the following tasks. Define a c

ID: 3676659 • Letter: O

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 constructor method that takes in make, model, year, andprice.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 theconstructorand 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:

Make:Toyota,

Model:Camry,

Year:1992,

Price:2000,

Speed Limit:180

Make:Honda,

Model:Accord,

Year:2002,

Price:6000,

Speed Limit:200

Instantiate (Create) at least three objects of WaterVehicle and display the properties of each object instance. Sample output is as follows:

Make:Mitsubishi,

Model:Turbo,

Year:1999,

Price:20000,

Boat Capacity:18

Make:Hyundai,

Model:XT,

Year:2012,

Price:26000,

Boat Capacity:8

IMPORTANT: PLEASE MAKE SURE THAT YOU HAD TESTED YOUR CODE BEFORE POSTING.

MAKE SURE THAT YOUR CODE MET ALL THE PROBLEM REQUIREMENTS.

YOU CAN USE < www.phptester.net > TO RUN YOUR CODE.

Make:Toyota,

Model:Camry,

Year:1992,

Price:2000,

Speed Limit:180

Make:Honda,

Model:Accord,

Year:2002,

Price:6000,

Speed Limit:200

Explanation / Answer

<?php
abstract class Vehicle
{
public abstract function getModel();
public function getMake()
{
return get_class($this);
}

public function getYear()
{
return get_class($this);
}

public function getPrice()
{
return get_class($this);
}

public function getCapacity()
{
return get_class($this);
}

class Car extends Vehicle
{
public function getModel()
{
return 4;
}
public function getMake()
{
return 4;
}
public function getYear()
{
return 4;
}
public function getPrice()
{
return 4;
}
public function getCapacity()
{
return 4;
}
}

class Bike extends Vehicle
{
public function getModel()
{
return 4;
}
public function getMake()
{
return 4;
}
public function getYear()
{
return 4;
}
public function getPrice()
{
return 4;
}
public function getCapacity()
{
return 4;
}
}

function print(Vehicle $v)
{

echo "A " . $v->getModel(). $v->getMake(). $v->getPrice(). $v->getYear().$v->getCapacity()
}
$car = new Car();
$bike = new Bike();
print($car);
print($bike);