From 68c7d13c570ab13c636deb71c0053ee051e7010e Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Sun, 17 Jul 2022 16:59:53 +1000 Subject: [PATCH] Add game loop --- 26_Chomp/csharp/Game.cs | 27 +++++++++++++++++++++++++++ 26_Chomp/csharp/Program.cs | 5 +++++ 2 files changed, 32 insertions(+) create mode 100644 26_Chomp/csharp/Game.cs create mode 100644 26_Chomp/csharp/Program.cs diff --git a/26_Chomp/csharp/Game.cs b/26_Chomp/csharp/Game.cs new file mode 100644 index 00000000..943eb95a --- /dev/null +++ b/26_Chomp/csharp/Game.cs @@ -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; } + } + } +} \ No newline at end of file diff --git a/26_Chomp/csharp/Program.cs b/26_Chomp/csharp/Program.cs new file mode 100644 index 00000000..f541259c --- /dev/null +++ b/26_Chomp/csharp/Program.cs @@ -0,0 +1,5 @@ +global using Games.Common.IO; +global using Chomp.Resources; +using Chomp; + +new Game(new ConsoleIO()).Play(); \ No newline at end of file