Skip to content

Commit

Permalink
Output a screen-full of MBIs by default
Browse files Browse the repository at this point in the history
The number of MBIs output will vary depending
on the dimensions of the terminal/console
window.
  • Loading branch information
tgharold committed Apr 2, 2020
1 parent 52f6eba commit 5ddf735
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/sombis/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace sombis
{
public class Generator
{
public const int MBILength = 11;

private static readonly Random _random = new Random();

public Generator()
Expand Down
20 changes: 12 additions & 8 deletions src/sombis/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ class Program
static void Main(string[] args)
{
var generator = new Generator();

const int iterations = 10;

for (var i = 1; i <= iterations; i++)
var consoleWidth = Console.WindowWidth;
var consoleHeight = Console.WindowHeight;
var perLineLimit = Math.Floor(((double)consoleWidth) / (Generator.MBILength + 1));

for (var row = 1; row <= consoleHeight - 1; row++)
{
var mbi = generator.CreateRandomMbi();

Console.WriteLine(mbi);
}
for (var col = 1; col <= perLineLimit; col++)
{
var mbi = generator.CreateRandomMbi();
Console.Write($"{mbi} ");
}
Console.WriteLine();
}
}

}
}

0 comments on commit 5ddf735

Please sign in to comment.