Skip to content

Instantly share code, notes, and snippets.

@ashcox
Last active June 20, 2018 12:59
Show Gist options
  • Save ashcox/81c82a94971d4c8cf66eeb5dfd80494d to your computer and use it in GitHub Desktop.
Save ashcox/81c82a94971d4c8cf66eeb5dfd80494d to your computer and use it in GitHub Desktop.
This door is not in use conumdrum
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
}
}
@ashcox
Copy link
Author

ashcox commented Jun 14, 2018

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment