refactoring of GameController.java to do it the same way as the other controllers.

This commit is contained in:
schrom01 2022-05-07 12:51:14 +02:00
parent ecde0e6345
commit 62df1db34b
4 changed files with 16 additions and 29 deletions

View File

@ -62,8 +62,8 @@ public class Factory {
FXMLLoader loader = new FXMLLoader(getClass().getResource("gameScheduleView/Game.fxml"));
box.getChildren().add(loader.load());
GameController controller = loader.getController();
controller.setup(new GameDecorator(game, tournamentDecorator));
controller.setup(tournamentDecorator, fileIO, factoryDecorator, box, new GameDecorator(game));
controller.loadContent();
} catch (IOException e) {
e.printStackTrace();
//TODO LOGGER

View File

@ -45,6 +45,10 @@ public class Game implements Serializable {
this.participant1 = participant1;
}
public void setParticipant2(Participant participant2) {
this.participant2 = participant2;
}
public Participant getParticipant2() {
return participant2;
}
@ -67,7 +71,4 @@ public class Game implements Serializable {
}
}
public void setParticipant2(Participant participant2) {
this.participant2 = participant2;
}
}

View File

@ -6,6 +6,7 @@ import javafx.fxml.FXML;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.Pane;
public class GameController extends FXController{
@ -29,10 +30,8 @@ public class GameController extends FXController{
@FXML
void saveGamerResult(ActionEvent event) {
gameDecorator.setPoints1(Integer.parseInt(pointsTeamOne.getText()));
gameDecorator.setPoints2(Integer.parseInt(pointsTeamTwo.getText()));
gameDecorator.setLocation(placesChoiceBox.getValue());
gameDecorator.getTournamentDecorator().refreshGameParticipants();
gameDecorator.saveGame(pointsTeamOne.getText(), pointsTeamTwo.getText(), placesChoiceBox.getValue());
getTournamentDecorator().refreshGameParticipants();
loadContent();
}
@ -44,9 +43,9 @@ public class GameController extends FXController{
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;
loadContent();
}
}

View File

@ -8,24 +8,16 @@ import java.util.List;
public class GameDecorator {
private Game game;
private TournamentDecorator tournamentDecorator;
private List<IsObserver> listener = new ArrayList<>();
public GameDecorator (Game game, TournamentDecorator tournamentDecorator) {
public GameDecorator (Game game) {
this.game = game;
this.tournamentDecorator = tournamentDecorator;
}
public TournamentDecorator getTournamentDecorator() {
return tournamentDecorator;
}
public void setPoints1(int points1) {
game.setPoints1(points1);
}
public void setPoints2(int points2) {
game.setPoints2(points2);
public void saveGame(String points1, String points2, Place place){
game.setPoints1(Integer.parseInt(points1));
game.setPoints2(Integer.parseInt(points2));
game.setPlace(place);
}
public String getPoints1() {
@ -53,9 +45,4 @@ public class GameDecorator {
public Place getLocation() {
return game.getPlace();
}
public void setLocation(Place place) {
game.setLocation(place);
}
}