refactoring of GameController.java to do it the same way as the other controllers.
This commit is contained in:
parent
ecde0e6345
commit
62df1db34b
|
@ -62,8 +62,8 @@ public class Factory {
|
||||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("gameScheduleView/Game.fxml"));
|
FXMLLoader loader = new FXMLLoader(getClass().getResource("gameScheduleView/Game.fxml"));
|
||||||
box.getChildren().add(loader.load());
|
box.getChildren().add(loader.load());
|
||||||
GameController controller = loader.getController();
|
GameController controller = loader.getController();
|
||||||
controller.setup(new GameDecorator(game, tournamentDecorator));
|
controller.setup(tournamentDecorator, fileIO, factoryDecorator, box, new GameDecorator(game));
|
||||||
|
controller.loadContent();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
//TODO LOGGER
|
//TODO LOGGER
|
||||||
|
|
|
@ -45,6 +45,10 @@ public class Game implements Serializable {
|
||||||
this.participant1 = participant1;
|
this.participant1 = participant1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setParticipant2(Participant participant2) {
|
||||||
|
this.participant2 = participant2;
|
||||||
|
}
|
||||||
|
|
||||||
public Participant getParticipant2() {
|
public Participant getParticipant2() {
|
||||||
return participant2;
|
return participant2;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +71,4 @@ public class Game implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParticipant2(Participant participant2) {
|
|
||||||
this.participant2 = participant2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.ChoiceBox;
|
import javafx.scene.control.ChoiceBox;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.scene.layout.Pane;
|
||||||
|
|
||||||
public class GameController extends FXController{
|
public class GameController extends FXController{
|
||||||
|
|
||||||
|
@ -29,10 +30,8 @@ public class GameController extends FXController{
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void saveGamerResult(ActionEvent event) {
|
void saveGamerResult(ActionEvent event) {
|
||||||
gameDecorator.setPoints1(Integer.parseInt(pointsTeamOne.getText()));
|
gameDecorator.saveGame(pointsTeamOne.getText(), pointsTeamTwo.getText(), placesChoiceBox.getValue());
|
||||||
gameDecorator.setPoints2(Integer.parseInt(pointsTeamTwo.getText()));
|
getTournamentDecorator().refreshGameParticipants();
|
||||||
gameDecorator.setLocation(placesChoiceBox.getValue());
|
|
||||||
gameDecorator.getTournamentDecorator().refreshGameParticipants();
|
|
||||||
loadContent();
|
loadContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,9 +43,9 @@ public class GameController extends FXController{
|
||||||
pointsTeamTwo.setText(String.valueOf(gameDecorator.getPoints2()));
|
pointsTeamTwo.setText(String.valueOf(gameDecorator.getPoints2()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setup(GameDecorator gameDecorator) {
|
public void setup(TournamentDecorator tournamentDecorator, FileIO fileIO, FactoryDecorator factoryDecorator, Pane pane, GameDecorator gameDecorator) {
|
||||||
|
super.setup(tournamentDecorator, fileIO, factoryDecorator, pane);
|
||||||
this.gameDecorator = gameDecorator;
|
this.gameDecorator = gameDecorator;
|
||||||
loadContent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -8,24 +8,16 @@ import java.util.List;
|
||||||
|
|
||||||
public class GameDecorator {
|
public class GameDecorator {
|
||||||
private Game game;
|
private Game game;
|
||||||
private TournamentDecorator tournamentDecorator;
|
|
||||||
private List<IsObserver> listener = new ArrayList<>();
|
private List<IsObserver> listener = new ArrayList<>();
|
||||||
|
|
||||||
public GameDecorator (Game game, TournamentDecorator tournamentDecorator) {
|
public GameDecorator (Game game) {
|
||||||
this.game = game;
|
this.game = game;
|
||||||
this.tournamentDecorator = tournamentDecorator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TournamentDecorator getTournamentDecorator() {
|
public void saveGame(String points1, String points2, Place place){
|
||||||
return tournamentDecorator;
|
game.setPoints1(Integer.parseInt(points1));
|
||||||
}
|
game.setPoints2(Integer.parseInt(points2));
|
||||||
|
game.setPlace(place);
|
||||||
public void setPoints1(int points1) {
|
|
||||||
game.setPoints1(points1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPoints2(int points2) {
|
|
||||||
game.setPoints2(points2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPoints1() {
|
public String getPoints1() {
|
||||||
|
@ -53,9 +45,4 @@ public class GameDecorator {
|
||||||
public Place getLocation() {
|
public Place getLocation() {
|
||||||
return game.getPlace();
|
return game.getPlace();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocation(Place place) {
|
|
||||||
game.setLocation(place);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue