How to separate payment strategy | Parking lot design
Hi I had a class which manages a parking lot. That class is called say for example, parking lot manager. I have a payment strategy stored in parking lot manager . This strategy is nothing but hourly payment or daily payment. Reason of storing it on manager is to avoid storing it into each and every vehicle object. But challenge is as below: For example, V1 came at 5 PM and that time, strategy was hourly basis. When it left at 11 PM, current strategy is no more hourly basis. How to handle this? I do not want to store strategy on vehicle object as it is duplicate on all the vehicle object and other issue is that it has nothing to do with vehicle. Vehicle is not something which decides the payment strategy , but it is parking lot which decides the strategy of payment. Please suggest.