Split classes to files

This commit is contained in:
drewjcooper
2023-04-22 08:09:50 +10:00
parent b2de1b09e1
commit 3e4fb4fe23
15 changed files with 434 additions and 419 deletions

View File

@@ -0,0 +1,27 @@
namespace Games.Common.IO;
internal static class IOExtensions
{
internal static Position ReadPosition(this IReadWrite io) => Position.Create(io.Read2Numbers(""));
internal static Position ReadValidPosition(this IReadWrite io)
{
while (true)
{
if (Position.TryCreateValid(io.Read2Numbers(""), out var position))
{
return position;
}
io.WriteLine("ILLEGAL, ENTER AGAIN.");
}
}
internal static IEnumerable<Position> ReadPositions(this IReadWrite io, string shipName, int shipSize)
{
io.WriteLine(shipName);
for (var i = 0; i < shipSize; i++)
{
yield return io.ReadPosition();
}
}
}