You are asked to simulate the functionality of “Gas & Co.” fuel station. The station
consists of a number of fuel pumps, initially three of them. Each pump contains an input
area, a display (status, amount being dispensed, amount of money), and a dispenser, and
gives out one type of fuel (diesel, gasoline, etc.). Each type of fuel has a variable price
that is configured on the fuel station price list. The fuel contained in a pump is of finite
size and needs to be refilled periodically in order to serve the customers. “Gas & Co.”
also registers regular customers and rewards them with special discounts according to
flexible business rules.
The station operator starts by selecting the pump, inputting the customer identity (if any,
otherwise considered an anonymous customer), and then entering either the amount of
fuel (depending on the pump configuration, can be litres, gallons, etc.) or the amount of
money. If there is available fuel, the dispenser starts dispensing fuel at a fixed rate,
reflected on the fuel station display (both amount and money), until the amount
requested is completely dispensed. Thus, the display is continuously notified as the state
of the fuel pump changes. Otherwise, if the requested fuel amount is not available, an
error is displayed on the display.
When the new customer arrives, the values are reset to 0. The pump makes sure it does
not accept new customer and fuel amount values while it is dispensing fuel, thus it
switches between different “states”. The customer of this application may require in the
future to upgrade the displays to fancier ones, thus replacing displays should not be too
difficult for programmers.
For anonymous customers, the charge is calculated from the amount of fuel (or, vice
versa, the amount of fuel is calculated from the amount of money) based on the simple
formula charge = (amount in units) x (price/unit). However, for registered customers,
special discounts may apply. The discount strategies are variable over time, such as
fixed percentage discount, fixed amount of discount if a certain amount threshold is
passed, free first litres/gallons, etc. These discount rules should be easily selected during
run time and new ones easily added to the application in the future.