summaryrefslogtreecommitdiff
path: root/projects/09/K/Board.jack
diff options
context:
space:
mode:
authorYuchen Pei <me@ypei.me>2018-01-18 12:39:31 +0100
committerYuchen Pei <me@ypei.me>2018-01-18 12:39:31 +0100
commit3d08a3b370316d14ab6d08209566464853005474 (patch)
tree437878db2a20cef7142e1eddb27dee355f8437a6 /projects/09/K/Board.jack
parent84445f00a572497784fb6d97e23bdd1e655f6e5d (diff)
refactored K
- no more heap waste.
Diffstat (limited to 'projects/09/K/Board.jack')
-rw-r--r--projects/09/K/Board.jack12
1 files changed, 3 insertions, 9 deletions
diff --git a/projects/09/K/Board.jack b/projects/09/K/Board.jack
index e9ed8a6..91a8d98 100644
--- a/projects/09/K/Board.jack
+++ b/projects/09/K/Board.jack
@@ -1,14 +1,7 @@
-/**
-improvments:
-- do in place transposition
-- add a static string boardBar = "+----+"
-- change printString("|") to printChar
-- change the grid to static variable?
-*/
class Board {
field Array grid;
field int nTurn, seed, status; // status: 0: begin game; 1: in game; 2: lose; 3: win;
- static String boardBar, strLost, strCont, strGameOver, strWon;
+ static String boardBar, strLost, strCont, strGameOver, strWon, strTurn;
constructor Board new() {
var int i;
@@ -29,6 +22,7 @@ class Board {
let strWon = "You won!";
let strCont = "Press any key to continue";
let strGameOver = "Game over!";
+ let strTurn = "Turn: ";
return;
}
@@ -320,7 +314,7 @@ class Board {
}
do Output.moveCursor(r + 6, c - 2);
- do Output.printString("Turn: ");
+ do Output.printString(strTurn);
do Output.printInt(nTurn);
}}}
return;