-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathBlackJackController.java
More file actions
42 lines (36 loc) · 1.2 KB
/
BlackJackController.java
File metadata and controls
42 lines (36 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package blackjack;
import blackjack.view.InputView;
import blackjack.view.OutputView;
import java.util.List;
import java.util.stream.Stream;
public class BlackJackController {
public static void main(String[] args) {
InputView inputView = new InputView();
OutputView outputView = new OutputView();
final List<String> names = inputView.insertPlayer();
List<Player> players = names.stream()
.map(name -> new Player(name))
.toList();
Dealer dealer = new Dealer();
//init
dealer.deal(dealer);
dealer.deal(dealer);
for(Player player : players) {
dealer.deal(player);
dealer.deal(player);
}
inputView.init(dealer, players);
for(Player player : players) {
while (inputView.isProvide(player.getName())) {
dealer.deal(player);
inputView.printCards(player);
}
}
while (outputView.isProvide(dealer)) {
dealer.deal(dealer);
}
outputView.printTotalScore(dealer, players);
final Table table = new Table(players, dealer);
outputView.printResult(table);
}
}