MCPcopy
hub / github.com/careercup/ctci / main

Method main

java/Chapter 8/Question8_1/Question.java:8–46  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

6
7
8 public static void main(String[] args) {
9 int numHands = 5;
10
11 BlackJackGameAutomator automator = new BlackJackGameAutomator(numHands);
12 automator.initializeDeck();
13 boolean success = automator.dealInitial();
14 if (!success) {
15 System.out.println("Error. Out of cards.");
16 } else {
17 System.out.println("-- Initial --");
18 automator.printHandsAndScore();
19 ArrayList<Integer> blackjacks = automator.getBlackJacks();
20 if (blackjacks.size() > 0) {
21 System.out.print("Blackjack at ");
22 for (int i : blackjacks) {
23 System.out.print(i + ", ");
24 }
25 System.out.println("");
26 } else {
27 success = automator.playAllHands();
28 if (!success) {
29 System.out.println("Error. Out of cards.");
30 } else {
31 System.out.println("\n-- Completed Game --");
32 automator.printHandsAndScore();
33 ArrayList<Integer> winners = automator.getWinners();
34 if (winners.size() > 0) {
35 System.out.print("Winners: ");
36 for (int i : winners) {
37 System.out.print(i + ", ");
38 }
39 System.out.println("");
40 } else {
41 System.out.println("Draw. All players have busted.");
42 }
43 }
44 }
45 }
46 }
47
48}

Callers

nothing calls this directly

Calls 8

initializeDeckMethod · 0.95
dealInitialMethod · 0.95
printHandsAndScoreMethod · 0.95
getBlackJacksMethod · 0.95
playAllHandsMethod · 0.95
getWinnersMethod · 0.95
sizeMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected