diff --git a/26_Chomp/csharp/Chomp.csproj b/26_Chomp/csharp/Chomp.csproj index d3fe4757..3870320c 100644 --- a/26_Chomp/csharp/Chomp.csproj +++ b/26_Chomp/csharp/Chomp.csproj @@ -6,4 +6,12 @@ enable enable + + + + + + + + diff --git a/26_Chomp/csharp/Resources/Coordinates.txt b/26_Chomp/csharp/Resources/Coordinates.txt new file mode 100644 index 00000000..e78dd644 --- /dev/null +++ b/26_Chomp/csharp/Resources/Coordinates.txt @@ -0,0 +1 @@ +Coordinates of Chomp (row, column) \ No newline at end of file diff --git a/26_Chomp/csharp/Resources/HereWeGo.txt b/26_Chomp/csharp/Resources/HereWeGo.txt new file mode 100644 index 00000000..00975d31 --- /dev/null +++ b/26_Chomp/csharp/Resources/HereWeGo.txt @@ -0,0 +1,2 @@ +Here we go... + diff --git a/26_Chomp/csharp/Resources/HowManyColumns.txt b/26_Chomp/csharp/Resources/HowManyColumns.txt new file mode 100644 index 00000000..e323f959 --- /dev/null +++ b/26_Chomp/csharp/Resources/HowManyColumns.txt @@ -0,0 +1 @@ +How many columns \ No newline at end of file diff --git a/26_Chomp/csharp/Resources/HowManyPlayers.txt b/26_Chomp/csharp/Resources/HowManyPlayers.txt new file mode 100644 index 00000000..98ff0ad7 --- /dev/null +++ b/26_Chomp/csharp/Resources/HowManyPlayers.txt @@ -0,0 +1 @@ +How many players \ No newline at end of file diff --git a/26_Chomp/csharp/Resources/HowManyRows.txt b/26_Chomp/csharp/Resources/HowManyRows.txt new file mode 100644 index 00000000..1ad9464e --- /dev/null +++ b/26_Chomp/csharp/Resources/HowManyRows.txt @@ -0,0 +1 @@ +How many rows \ No newline at end of file diff --git a/26_Chomp/csharp/Resources/Introduction.txt b/26_Chomp/csharp/Resources/Introduction.txt new file mode 100644 index 00000000..7c95e7a6 --- /dev/null +++ b/26_Chomp/csharp/Resources/Introduction.txt @@ -0,0 +1,6 @@ + Chomp + Creative Computing Morristown, New Jersey + + + +This is the game of Chomp (Scientific American, Jan 1973) diff --git a/26_Chomp/csharp/Resources/Player.txt b/26_Chomp/csharp/Resources/Player.txt new file mode 100644 index 00000000..60f9ba5e --- /dev/null +++ b/26_Chomp/csharp/Resources/Player.txt @@ -0,0 +1,2 @@ +Player {0} +Player {0} \ No newline at end of file diff --git a/26_Chomp/csharp/Resources/Resource.cs b/26_Chomp/csharp/Resources/Resource.cs new file mode 100644 index 00000000..e1f06e39 --- /dev/null +++ b/26_Chomp/csharp/Resources/Resource.cs @@ -0,0 +1,42 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +namespace Chomp.Resources; + +internal static class Resource +{ + internal static class Streams + { + public static Stream HereWeGo => GetStream(); + public static Stream Introduction => GetStream(); + public static Stream Rules => GetStream(); + public static Stream TooManyColumns => GetStream(); + public static Stream TooManyRows => GetStream(); + } + + internal static class Formats + { + public static string Player => GetString(); + public static string YouLose => GetString(); + } + + internal static class Prompts + { + public static string Coordinates => GetString(); + public static string HowManyPlayers => GetString(); + public static string HowManyRows => GetString(); + public static string HowManyColumns => GetString(); + } + + private static string GetString([CallerMemberName] string? name = null) + { + using var stream = GetStream(name); + using var reader = new StreamReader(stream); + return reader.ReadToEnd(); + } + + + private static Stream GetStream([CallerMemberName] string? name = null) => + Assembly.GetExecutingAssembly().GetManifestResourceStream($"{typeof(Resource).Namespace}.{name}.txt") + ?? throw new Exception($"Could not find embedded resource stream '{name}'."); +} \ No newline at end of file diff --git a/26_Chomp/csharp/Resources/Rules.txt b/26_Chomp/csharp/Resources/Rules.txt new file mode 100644 index 00000000..2fd9177f --- /dev/null +++ b/26_Chomp/csharp/Resources/Rules.txt @@ -0,0 +1,22 @@ +Chomp is for 1 or more players (humans only). + +Here's how a board looks (this one is 5 by 7): + + 1 2 3 4 5 6 7 8 9 + 1 P * * * * * * + 2 * * * * * * * + 3 * * * * * * * + 4 * * * * * * * + 5 * * * * * * * + + +The board is a big cookie - R rows high and C columns +wide. You input R and C at the start. In the upper left +corner of the cookie is a poison square (P). The one who +chomps the poison square loses. To take a chomp, type the +row and column of one of the squares on the cookie. +All of the squares below and to the right of that square +(including that square, too) disappear -- Chomp!! +No fair chomping on squares that have already been chomped, +or that are outside the original dimensions of the cookie. + diff --git a/26_Chomp/csharp/Resources/TooManyColumns.txt b/26_Chomp/csharp/Resources/TooManyColumns.txt new file mode 100644 index 00000000..1e8766a7 --- /dev/null +++ b/26_Chomp/csharp/Resources/TooManyColumns.txt @@ -0,0 +1 @@ +Too many rows (9 is maximum). Now, \ No newline at end of file diff --git a/26_Chomp/csharp/Resources/TooManyRows.txt b/26_Chomp/csharp/Resources/TooManyRows.txt new file mode 100644 index 00000000..1e8766a7 --- /dev/null +++ b/26_Chomp/csharp/Resources/TooManyRows.txt @@ -0,0 +1 @@ +Too many rows (9 is maximum). Now, \ No newline at end of file diff --git a/26_Chomp/csharp/Resources/YouLose.txt b/26_Chomp/csharp/Resources/YouLose.txt new file mode 100644 index 00000000..c6e22300 --- /dev/null +++ b/26_Chomp/csharp/Resources/YouLose.txt @@ -0,0 +1 @@ +You lose, player {0} \ No newline at end of file