Add comments and tasks

This commit is contained in:
Dave Burke
2022-02-09 21:40:27 -06:00
parent 2b2f9327f7
commit f65c2de058
3 changed files with 51 additions and 8 deletions

View File

@@ -8,11 +8,14 @@ public class Blackjack {
public static void main(String[] args) {
// Intuitively it might seem like the main program logic should be right
// here in 'main' and that we should just use System.in and System.out
// directly whenever we need them. However, by externalizing the source
// of input/output data (and the ordering of the cards via a custom
// shuffle function), we can write non-interactive and deterministic
// tests of the code. See UserIoTest as an example.
try (Reader in = new InputStreamReader(System.in)) {
// directly whenever we need them. However, notice that System.out and
// System.in are just an OutputStream and InputStream respectively. By
// allowing alternate streams to be specified to Game at runtime, we can
// write non-interactive tests of the code. See UserIoTest as an
// example.
// Likewise, by allowing an alternative "shuffle" algorithm, test code
// can provide a deterministic card ordering.
try (Reader in = new InputStreamReader(System.in)) {
Writer out = new OutputStreamWriter(System.out);
UserIo userIo = new UserIo(in, out);
Deck deck = new Deck(cards -> {