mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-23 07:29:02 -08:00
Add game loop
This commit is contained in:
27
26_Chomp/csharp/Game.cs
Normal file
27
26_Chomp/csharp/Game.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
namespace Chomp;
|
||||
|
||||
internal class Game
|
||||
{
|
||||
private readonly IReadWrite _io;
|
||||
|
||||
public Game(IReadWrite io)
|
||||
{
|
||||
_io = io;
|
||||
}
|
||||
|
||||
internal void Play()
|
||||
{
|
||||
_io.Write(Resource.Streams.Introduction);
|
||||
if (_io.ReadNumber("Do you want the rules (1=Yes, 0=No!)") != 0)
|
||||
{
|
||||
_io.Write(Resource.Streams.Rules);
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
_io.Write(Resource.Streams.HereWeGo);
|
||||
|
||||
if (_io.ReadNumber("Again (1=Yes, 0=No!)") != 1) { break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user