Passing an object to an abstract class?
Hi. I am new to this forum, and have registered to ask questions when I don't understand the assignments provided for the programming courses I take. My instructor doesn't speak the best English, so sometimes it's hard to understand what he's asking for.
The first part of the assignment, which I have already completed, is as follows:
A mechanic shop has 100 customers, each of which is an object in an array, which holds various data. The Base class is Service, and there are four derived classes for specific services (tires, oil, radiator, and brakes). Each customer is assigned one service. A list of all customers with the details is printed.
The second part, I do not understand what he is asking for at all:
We are printing coupons if the last service was done over a certain number of months ago. I have already made calculations for the dates, and if the service was done a certain amount of time ago, I need to pass one object in the service array to the abstract coupon class. His exact instructions are these:
Here is what I think it is asking for (purely as an exercise for demonstrating we know how to use abstract and inheritance):
Coupon is an Abstract parent class. The abstract class should have variable year, month and day. Make a Service Coupon extend the Abstract coupon class. Several child classes - BrakeService Coupon, Tire Coupon, Engine Oil Coupon, Radiator Coupon extend the Service Coupons. Add an Expiry date to a random date in 2013 and Make it final in the constructor of the objects. The service object calls the coupon passing the service object. The coupon determines the type of service object it receives and accordingly prints the message. This should be simple.
Am I supposed to be passing the object to the abstract class? If so, am I supposed to take my main class and make it an extension of the abstract coupon class?
Sorry that I can't be more clear. I don't know what he wants either.
Thank you in advance,