mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-30 14:42:03 -08:00
Add comments and tasks
This commit is contained in:
@@ -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 -> {
|
||||
|
||||
Reference in New Issue
Block a user