Automotive counterparts are never perfect, because cars and engines are actually very complex systems. You have to ignore a lot of things just to simulate them. Your problem is that you do not seem to understand how the engine works.
The oil pan is part of the engine, not the car. The gas tank is part of the car, but not the engine. You have an oil pump (also part of the engine) that pumps oil into the engine cylinders. Most cars (perhaps all) do not “check the oil level” and refuse to start. The engine will just catch if it does not get enough oil. Similarly, if he does not receive enough gas, he does not check the gas tank level. It just runs out of fuel.
It will be something like this:
class Car { Engine engine; GasTank gasTank; StartEngine() { engine.Start(); } } class Engine { Timer timer; OilPan oilPan; OilPump oilPump; public Engine() { oilPump = new OilPump(oilPan, this); } Start() { timer.Start(oilPump); } InjectOil() {} } class Timer { OilPump op;
The timer informs about the rotation of the engine, when it rotates, it drives the oil pump, which pumps oil into the cylinders. Oil is not usually consumed as fuel. It is being recycled. It can break down over time, and in some engines that are in poor condition, it can burn.
The reference to the oil pump is a mechanical connection between the engine and the oil pump (as a rule, gears rotate it). The timer does not have an oil pump; it has a link to an oil pump.
A gas tank would work in a similar way.
Again, all this is imperfect (very imperfect), because so many are lacking.
Erik funkenbusch
source share