mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-23 15:37:51 -08:00
Add Damage Control
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user