Add Damage Control

This commit is contained in:
Andrew Cooper
2021-03-01 22:53:22 +11:00
parent 4d1a9176ec
commit 8c397ea8f9
19 changed files with 200 additions and 36 deletions

View File

@@ -72,5 +72,26 @@ namespace SuperStarTrek
_output.WriteLine();
}
}
public bool GetYesNo(string prompt, YesNoMode mode)
{
_output.Prompt($"{prompt} (Y/N)");
var response = Console.ReadLine().ToUpperInvariant();
return (mode, response) switch
{
(YesNoMode.FalseOnN, "N") => false,
(YesNoMode.FalseOnN, _) => true,
(YesNoMode.TrueOnY, "Y") => true,
(YesNoMode.TrueOnY, _) => false,
_ => throw new ArgumentOutOfRangeException(nameof(mode), mode, "Invalid value")
};
}
public enum YesNoMode
{
TrueOnY,
FalseOnN
}
}
}