Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create PHP classes ParkingInvoice and Car, which are used in a paid parking lot. Class Car contains one private property: licensePlate. It also has a

Create PHP classes ParkingInvoice and Car, which are used in a paid parking lot. Class Car contains one private property: licensePlate. It also has a parameterized constructor that initializes the license plate, as well as a getter method for this property.

Class ParkingInvoice contains a private Car reference and private properties hours and hourlyCharge. It has a parameterized constructor that initializes the Car and the two other properties. For hours and hourlyCharge, it checks for non-negative values, else they are initialised to zero. It also has getters for car and the two properties, as well as a setter for hourlyCharge. Also, ParkingInvoice contains method findCharge(), which returns the total parking charge.

Test both classes in a PHP script that creates an array of several ParkingInvoices with different Cars. Then, in a loop it displays all invoices in the array in an unordered list, where for each invoice is displayed the string Charge for (licence plate) is (charge).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Combinatorial Testing In Cloud Computing

Authors: Wei-Tek Tsai ,Guanqiu Qi

1st Edition

9811044805, 978-9811044809

More Books

Students also viewed these Programming questions

Question

Would I be a more effective student if I spent less time online?

Answered: 1 week ago