Add code examples, and documentation

This commit is contained in:
Aaron Po
2026-08-12 00:03:32 -04:00
commit 77c16e69f6
79 changed files with 4458 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
#region
using WithStatePattern.States;
#endregion
namespace WithStatePattern;
public class Car
{
private State _state;
public Car()
{
ChangeState(new Off(this));
}
public bool HandleInput(string input)
{
switch (input)
{
case "turn-clockwise":
_state.TurnKeyClockwise();
break;
case "turn-counter":
_state.TurnKeyCounterClockwise();
break;
case "gas":
_state.PressGas();
break;
case "brake":
_state.PressBrake();
break;
case "exit":
return false;
}
return true;
}
public void ChangeState(State state)
{
_state = state;
}
}