simplify mains
This commit is contained in:
@@ -11,12 +11,10 @@ import chess.view.consolerender.Console;
|
|||||||
|
|
||||||
public class ConsoleMain {
|
public class ConsoleMain {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
CommandExecutor commandExecutor = new CommandExecutor();
|
|
||||||
|
|
||||||
Game game = new Game(new ChessBoard());
|
Game game = new Game(new ChessBoard());
|
||||||
Console console = new Console(commandExecutor);
|
CommandExecutor commandExecutor = new CommandExecutor(game);
|
||||||
|
|
||||||
commandExecutor.setGame(game);
|
Console console = new Console(commandExecutor);
|
||||||
commandExecutor.addListener(console);
|
commandExecutor.addListener(console);
|
||||||
|
|
||||||
commandExecutor.executeCommand(new NewGameCommand());
|
commandExecutor.executeCommand(new NewGameCommand());
|
||||||
|
|||||||
@@ -8,12 +8,10 @@ import chess.view.simplerender.Window;
|
|||||||
|
|
||||||
public class SwingMain {
|
public class SwingMain {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
CommandExecutor commandExecutor = new CommandExecutor();
|
|
||||||
|
|
||||||
Game game = new Game(new ChessBoard());
|
Game game = new Game(new ChessBoard());
|
||||||
Window window = new Window(commandExecutor);
|
CommandExecutor commandExecutor = new CommandExecutor(game);
|
||||||
|
|
||||||
commandExecutor.setGame(game);
|
Window window = new Window(commandExecutor);
|
||||||
commandExecutor.addListener(window);
|
commandExecutor.addListener(window);
|
||||||
|
|
||||||
commandExecutor.executeCommand(new NewGameCommand());
|
commandExecutor.executeCommand(new NewGameCommand());
|
||||||
|
|||||||
@@ -13,7 +13,11 @@ public class CommandExecutor {
|
|||||||
private final GameDispatcher dispatcher;
|
private final GameDispatcher dispatcher;
|
||||||
|
|
||||||
public CommandExecutor() {
|
public CommandExecutor() {
|
||||||
this.game = null;
|
this(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandExecutor(Game game) {
|
||||||
|
this.game = game;
|
||||||
this.dispatcher = new GameDispatcher();
|
this.dispatcher = new GameDispatcher();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user