-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConsoleOutput.cs
57 lines (52 loc) · 1.71 KB
/
ConsoleOutput.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Text;
using KingsTableConsoleEdition.Interfaces;
namespace KingsTableConsoleEdition
{
public class ConsoleOutput : IOutput
{
public ConsoleOutput()
{
Console.WriteLine("Welcome to 'King's Table: Console Edition'");
Console.WriteLine("-built by c.s.tilstra-");
}
public void ShowBoard(char[,] board)
{
String separator = "|";
Console.WriteLine("");
// build top guide line
StringBuilder builder = new StringBuilder();
builder.Append(" ");
for (int j = 0; j < board.GetLength(1); j++)
{
builder.Append((char)(j + 108)); // convert to lowercase letters
builder.Append(" ");
}
Console.WriteLine(builder);
for (int i = 0; i < board.GetLength(0); i++)
{
builder = new StringBuilder();
// add left guide line entry
builder.Append((char)(i + 97)); // convert to lowercase letters
builder.Append(" ");
// add rest of line
builder.Append(separator);
for (int j = 0; j < board.GetLength(1); j++)
{
builder.Append(board[i, j].ToString());
builder.Append(separator);
}
Console.WriteLine(builder);
}
Console.WriteLine("");
}
public void ShowResult()
{
Console.WriteLine("The game result will go here");
}
public void PrintString(string toPrint)
{
Console.WriteLine(toPrint);
}
}
}