Design a parking lot kiosk.
Sigiloso
Software development is about finding the balance between various desired qualities of programs that often come at the expanse of each other. For example, efficiency often comes at the expanse of development time and code complexity. In real world situation, I would begin the design process by thoroughly understanding requirements. I would seek the answers to questions like: -What's the capacity of the parking lot? -What's the avg/max/variance of the rate of vehicle input? output? -What's the tolerance for traffic jam at entrance? exit? -Who are the users? Are they regulars or use the lot only once? -How many entrances? Exits? -What's the devel time requirmenment? -Is this code a one-off or be reused? Since this is just an interview, I'll assume that this parking lot has 100 spots, one entrance, which is also the exit and that the input/output rates are low enough that traffic jams are non-issue. When the vehicle enters, the ticket booth issues a time-stamped ticket to the vehicle. When the vehicle leaves, the ticket booth accepts the ticket, notifies the vehicle of the costs and accepts payment. It assumes well behaved drivers that always pay correct amount with exact change. class TicketBooth{ public: Ticket onVehicleEnter(); Price onVehicleExit(Ticket); void acceptPayment(Money); }