Tournament list #11

Merged
schrom01 merged 13 commits from TournamentList into main 2022-05-01 18:45:02 +02:00
2 changed files with 12 additions and 5 deletions
Showing only changes of commit 5034203409 - Show all commits

View File

@ -46,6 +46,15 @@ public class FileIO {
return tournamentFiles; return tournamentFiles;
} }
public boolean tournamentExists(String name){
for(TournamentFile file : getList()) {
if(file.toString().toLowerCase().equals(name.toLowerCase())){
return true;
}
}
return false;
}
/** /**
* @param tournamentFile * @param tournamentFile
* @return * @return

View File

@ -53,11 +53,9 @@ public class TournamentListController extends FXController {
@FXML @FXML
void createTournament(ActionEvent event) { void createTournament(ActionEvent event) {
for(FileIO.TournamentFile file : getFileIO().getList()) { if(getFileIO().tournamentExists(tournamentNameField.getText())){
if(file.toString().equals(tournamentNameField.getText())){ System.out.println("Tournament with same name exists already.");
return; //TODO handle and logging return; //TODO handle and logging
// Tournament with same name exists already.
}
} }
try { try {
Tournament tournament = new Tournament(tournamentNameField.getText(), modusChoiceBox.getValue()); Tournament tournament = new Tournament(tournamentNameField.getText(), modusChoiceBox.getValue());