Employee e = DB.getEmployee("Bob");
if (e != null && e.isTimeToPay(today))
e.pay();
Employee e = DB.getEmployee("Bob");
if (e.isTimeToPay(today))
e.pay();
public class NullEmployee: Employee{
public bool isTimeToPay(Date today){
return false;
}
public void pay(){
// do nothing
}
}
// Scheduler
public void Run()
{
while (!_cancellationTokenScheduler.IsCancellationRequested &&
_onSchedulerRunningEvent.WaitOne())
{
...
var ecr = _simulatorResult.Satellite.Orbit.SatPosKmECR;
_gpsSimulator.UpdateECEF(currentDateTime, ecr[0], ecr[1], ecr[2]);
...
}
}
void init()
{
_ibManager = new IBManager();
_subSimulator = new SubSimulator();
...
_gpsSimulator = GpsSimulatorFactory.Create(gpsConfigFile);
}
public interface IGpsSimulator
{
void Init(DateTime startTime);
void Start();
void Stop();
void UpdateECEF(DateTime currentDateTime, double x, double y, double z);
TimeSpan GetSimulationElapsedTime();
}
public class NullGpsSimulator : IGpsSimulator
{
private static NullGpsSimulator _instance = null;
private NullGpsSimulator() {}
public static NullGpsSimulator Instance()
{
if (_instance == null)
_instance = new NullGpsSimulator();
return _instance;
}
public void Init(DateTime startTime)
{
// Do Nothing
}
public void Start()
{
// Do Nothing
}
public void Stop()
{
// Do Nothing
}
public void UpdateECEF(DateTime currentDateTime, double x, double y, double z)
{
// Do Nothing
}
public TimeSpan GetSimulationElapsedTime()
{
return TimeSpan.Zero;
}
}