Last active
June 20, 2018 12:59
-
-
Save ashcox/81c82a94971d4c8cf66eeb5dfd80494d to your computer and use it in GitHub Desktop.
This door is not in use conumdrum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Door { | |
public Door(bool closed, bool hasNotInUseSign) { | |
this.InUse = closed; | |
this.HasNotInUseSign = hasNotInUseSign; | |
} | |
public State State => this.GetState(); | |
private State GetState() { | |
if (InUse && !HasNotInUseSign) { | |
return InUseAndFunctional; | |
} | |
if (InUse && HasNotInUseSign) { | |
return InUseAndNotFunctional; | |
} | |
if (!InUse && !HasNotInUseSign) { | |
return NotInUseAndFunctional; | |
} | |
if (!InUse && HasNotInUseSign) { | |
return NotInUseAndNotFunctional; | |
} | |
} | |
public void CloseDoor() | |
{ | |
this.InUse = true; | |
} | |
public void OpenDoor() | |
{ | |
this.InUse = false; | |
} | |
public void AddNotInUseSign() | |
{ | |
this.HasNotInUseSign = true; | |
} | |
public void RemoveNotInUseSign() | |
{ | |
this.HasNotInUseSign = false; | |
} | |
public bool InUse { get; private set; } | |
public bool HasNotInUseSign { get; private set; } | |
public enum State { | |
InUseAndFunctional, | |
InUseAndNotFunctional, | |
NotInUseAndFunctional, | |
NotInUseAndNotFunctional | |
} | |
} |
Author
ashcox
commented
Jun 14, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment