mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 15:16:33 -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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
5
26_Chomp/csharp/Program.cs
Normal file
5
26_Chomp/csharp/Program.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
global using Games.Common.IO;
|
||||
global using Chomp.Resources;
|
||||
using Chomp;
|
||||
|
||||
new Game(new ConsoleIO()).Play();
|
||||
Reference in New Issue
Block a user