forked from bark20/java-bridge
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGameContext.java
More file actions
31 lines (27 loc) · 1.1 KB
/
GameContext.java
File metadata and controls
31 lines (27 loc) · 1.1 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
package bridge;
/**
* 게임의 다양한 컴포넌트를 하나의 컨텍스트로 묶어서 사용하기 쉽게 관리하는 클래스
*/
public class GameContext {
InputView inputView;
OutputView outputView;
BridgeMaker bridgeMaker;
BridgeGame bridgeGame;
public GameContext (InputView inputView, OutputView outputView, BridgeMaker bridgeMaker, BridgeGame bridgeGame) {
this.inputView = inputView;
this.outputView = outputView;
this.bridgeMaker = bridgeMaker;
this.bridgeGame = bridgeGame;
}
/**
* 게임의 모든 컴포넌트를 초기화하고 GameContext 객체를 생성하는 팩토리 메서드
*/
public static GameContext createBridgeGame() {
InputView inputView = new InputView();
OutputView outputView = new OutputView();
BridgeRandomNumberGenerator numberGenerator = new BridgeRandomNumberGenerator();
BridgeMaker bridgeMaker = new BridgeMaker(numberGenerator);
BridgeGame bridgeGame = new BridgeGame();
return new GameContext(inputView, outputView, bridgeMaker, bridgeGame);
}
}