educative.io

Are each of these classes supposed to be separate modules? There seems to be a circular dependency

The Vehicle abstract class and its subclass declare the function “assignTicket(ParkingTicket ticket)”, but ParkingTicket has a declaration on Vehicle? Is this intentional?

Hi @KseoDilla,

A constructor has been called for initializing a parking ticket for the parent abstract vehicle class, which is a virtual function. It simply assigns an instance of a parking ticket to a vehicle. As soon as the parking ticket is assigned to a specific vehicle, based on the vehicle type, the parking ticket is updated. Since we have four vehicle types and four types of parking spots, every type of parking spot has its own charge/can be free; hence the parking ticket is again assigned in the derived classes.

We hope Educative has inspired you to further your learning, and please drop us a note if you have any other questions or concerns. :slightly_smiling_face: