public bool Validate(IBinService binService) { var(Angle, Level) = binService.GetSensorReadings(); var isValidated = false; if (Angle >= MIN_ANGLE && Level <= MAX_LEVEL) { Console.WriteLine("Bin is open"); isValidated = true; } this.lidState = Level >= MAX_LEVEL ? OverflowLidState.Instance : ClosedLidState.Instance; return(isValidated); }
public bool Validate(IBinService binService) { var (Angle, Level) = binService.GetSensorReadings(); var isValidated = false; if (Angle <= MAX_ANGLE) { if(Level >= MAX_LEVEL) { Console.WriteLine("Bin is full"); isValidated = true; } else { Console.WriteLine("Bin is closed"); isValidated = true; } } this.lidState = Level >= MAX_LEVEL ? OverflowLidState.Instance : OpenLidState.Instance; return isValidated; }
public void Transition(ILidState lidState) { this.lidState = lidState ?? throw new NullReferenceException(nameof(lidState)); }
public BinService(int angle, int level) { this.lidState = ClosedLidState.Instance; this.angle = angle; this.level = level; }