Skip to content

Commit 2ca5e3c

Browse files
author
Daniel Barclay
committed
ManualTicTacToe: Narrowed lots to private / private[ui].
1 parent 92e26d0 commit 2ca5e3c

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/main/scala/com/us/dsb/explore/algs/ttt/manual/ui/GameUI.scala

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,32 @@ object GameUI {
1919

2020
// ?? revisit name
2121
trait SegregatedTextIO {
22-
def printStateText(lineOrLines: String): Unit
23-
def readPromptedLine(prompt: String): String
24-
def printError(fullLine: String): Unit
22+
private[ui] def printStateText(lineOrLines: String): Unit
23+
private[ui] def readPromptedLine(prompt: String): String
24+
private[ui] def printError(fullLine: String): Unit
2525
// ?? first, second, or both?:
26-
def printResult(lineOrLines: String): Unit
27-
def printResult(result: GameUIResult): Unit = printResult(result.text)
26+
private[ui] def printResult(lineOrLines: String): Unit
27+
private[ui] def printResult(result: GameUIResult): Unit = printResult(result.text)
2828
}
2929

3030
class BaseConsoleTextIO extends SegregatedTextIO {
3131
import scala.io.StdIn.readLine
3232

33-
override def printStateText(lineOrLines: String): Unit = println(lineOrLines)
34-
override def readPromptedLine(prompt: String): String = readLine(prompt)
35-
override def printError(fullLine: String): Unit = println(fullLine)
36-
override def printResult(lineOrLines: String): Unit = println(lineOrLines)
33+
private[ui] override def printStateText(lineOrLines: String): Unit = println(lineOrLines)
34+
private[ui] override def readPromptedLine(prompt: String): String = readLine(prompt)
35+
private[ui] override def printError(fullLine: String): Unit = println(fullLine)
36+
private[ui] override def printResult(lineOrLines: String): Unit = println(lineOrLines)
3737
}
3838

3939
object PlainConsoleTextIO extends BaseConsoleTextIO
4040

4141
object ColoredConsoleTextIO extends BaseConsoleTextIO {
4242
import scala.io.AnsiColor._
43-
override def readPromptedLine(prompt: String): String =
43+
private[ui] override def readPromptedLine(prompt: String): String =
4444
super.readPromptedLine(BLUE + prompt + RESET)
45-
override def printError(fullLine: String): Unit =
45+
private[ui] override def printError(fullLine: String): Unit =
4646
super.printError(RED + fullLine + RESET)
47-
override def printResult(lineOrLines: String): Unit =
47+
private[ui] override def printResult(lineOrLines: String): Unit =
4848
super.printResult(BOLD + lineOrLines + RESET)
4949
}
5050

src/main/scala/com/us/dsb/explore/algs/ttt/manual/ui/GameUIState.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package com.us.dsb.explore.algs.ttt.manual.ui
33
import com.us.dsb.explore.algs.ttt.manual.game._
44

55
// ?? somewhere expand to allow for history (maybe via Semigroup or whatever has .compose?)
6-
case class GameUIState(gameState: GameState,
7-
selectedRow: RowIndex,
8-
selectedColumn: ColumnIndex) {
6+
private case class GameUIState(gameState: GameState,
7+
selectedRow: RowIndex,
8+
selectedColumn: ColumnIndex) {
99

1010
// ?? clean up that floorMod; I just want plain mathematical mod:
1111
private def adjustAndwrapToRange(unincremented: Index, delta: Int): Index = {
@@ -24,10 +24,10 @@ case class GameUIState(gameState: GameState,
2424
// our cursor-based row/column specification; what would GUI use, just
2525
// 9 table-level IDs tied to GUI cells/buttons?);
2626

27-
def withRowAdustedBy(delta: Int): GameUIState =
27+
private[ui] def withRowAdustedBy(delta: Int): GameUIState =
2828
copy(selectedRow = RowIndex(adjustAndwrapToRange(selectedRow.value, delta)))
2929

30-
def withColumnAdustedBy(delta: Int): GameUIState =
30+
private[ui] def withColumnAdustedBy(delta: Int): GameUIState =
3131
copy(selectedColumn = ColumnIndex(adjustAndwrapToRange(selectedColumn.value, delta)))
3232

3333
private def renderTableMultilineWithSelection: String = {
@@ -57,7 +57,7 @@ case class GameUIState(gameState: GameState,
5757

5858
}
5959

60-
def toDisplayString: String = {
60+
private[ui] def toDisplayString: String = {
6161
renderTableMultilineWithSelection + "\n" +
6262
s"Turn: Player ${gameState.currentPlayer}; marking cursor: <row $selectedRow / column $selectedColumn>"
6363
}

0 commit comments

Comments
 (0)