mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-25 12:25:10 -08:00
32 lines
696 B
C#
32 lines
696 B
C#
using static Poetry.Resources.Resource;
|
|
|
|
namespace Poetry;
|
|
|
|
internal class Poem
|
|
{
|
|
internal static void Compose(IReadWrite io, IRandom random)
|
|
{
|
|
io.Write(Streams.Title);
|
|
|
|
var context = new Context(io, random);
|
|
|
|
while (true)
|
|
{
|
|
context.WritePhrase();
|
|
context.MaybeWriteComma();
|
|
context.WriteSpaceOrNewLine();
|
|
|
|
while (true)
|
|
{
|
|
context.Update(random);
|
|
context.MaybeIndent();
|
|
|
|
if (context.GroupNumberIsValid) { break; }
|
|
|
|
context.ResetGroup(io);
|
|
|
|
if (context.MaybeCompleteStanza()) { break; }
|
|
}
|
|
}
|
|
}
|
|
} |