diff --git a/cell.go b/cell.go index 5211a80..9c1149a 100644 --- a/cell.go +++ b/cell.go @@ -9,7 +9,13 @@ import ( ) const ( - aliveChar = '*' + aliveCellInput = '*' + deadCellInput = '.' + + aliveCellOutput = "● " + deadCellOutput = " " + newLineOutput = "\n" + aliveCell cell = 1 deadCell cell = 0 ) @@ -36,7 +42,7 @@ func newCells(input []string) (cells, error) { if len(input[i]) <= j { continue } - if input[i][j] == aliveChar { + if input[i][j] == aliveCellInput { cells[i][j] = aliveCell } } @@ -137,14 +143,14 @@ func (c cells) print(w io.StringWriter) { for i := 0; i < c.height(); i++ { for j := 0; j < c.width(); j++ { if c[i][j] == aliveCell { - w.WriteString("● ") + w.WriteString(aliveCellOutput) continue } - w.WriteString(" ") + w.WriteString(deadCellOutput) } - w.WriteString("\n") + w.WriteString(newLineOutput) } } diff --git a/cell_test.go b/cell_test.go index 7938476..4c383b6 100644 --- a/cell_test.go +++ b/cell_test.go @@ -86,8 +86,8 @@ func TestCells(t *testing.T) { } func mockPrint(line string) string { - l := strings.Replace(line, ".", " ", -1) - l = strings.Replace(l, "*", "● ", -1) + l := strings.Replace(line, string(deadCellInput), deadCellOutput, -1) + l = strings.Replace(l, string(aliveCellInput), aliveCellOutput, -1) l += "\n" return l }