diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/FileIO.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/FileIO.java index 8549e8a..1b50e7f 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/FileIO.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/FileIO.java @@ -4,7 +4,14 @@ package ch.zhaw.projekt2.turnierverwaltung; import javafx.collections.FXCollections; import javafx.collections.ObservableList; -import java.io.*; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; import java.net.URI; import java.util.logging.Logger; @@ -12,8 +19,8 @@ import java.util.logging.Logger; * Class in Charge of Reading and Writing files */ public class FileIO { - private File mainDir; - private File saves; + private final File mainDir; + private final File saves; private static final Logger logger = Logger.getLogger(FileIO.class.getCanonicalName()); @@ -57,13 +64,14 @@ public class FileIO { /** * Method to check if a tournament with the existing name already exists. + * * @param name that is being checked * @return true if the name exists already false if the name is unique */ public boolean tournamentExists(String name) { logger.finer("checking for duplicate name in tournament List"); for (TournamentFile file : getList()) { - if (file.toString().toLowerCase().equals(name.toLowerCase())) { + if (file.toString().equalsIgnoreCase(name)) { logger.fine(name + " is an already existing name in the list"); return true; } @@ -73,10 +81,10 @@ public class FileIO { } /** - * Loads and returns a tournament from a given File which contains the serialiazed tournament. + * Loads and returns a tournament from a given File which contains the serialized tournament. * * @param tournamentFile The tournament file where the data should be read from. - * @return Tournament that is returned when succefully being read from the file + * @return Tournament that is returned when successfully being read from the file * @throws ClassNotFoundException No definition for the class with the specified name could be found * @throws IOException File not readable * @throws FileNotFoundException File not found @@ -119,7 +127,7 @@ public class FileIO { } /** - * Serializables and saves the receiving tournament file to a txt file. + * Serializable and saves the receiving tournament file to a txt file. * * @param tournament the receiving tournament. * @throws IOException File not readable @@ -181,14 +189,14 @@ public class FileIO { } /** - * TournamentFile Class is in use to add missing functionality that is + * TournamentFile Class is in used to add missing functionality that is */ - public class TournamentFile extends File { + public static class TournamentFile extends File { /** * Only job the constructor got is to initialize it via its superclass. See java.io.File Documentation for more info. * - * @param uri abstract pathname needed for its superclass to intialize the file accordingly. + * @param uri abstract pathname needed for its superclass to initialize the file accordingly. */ public TournamentFile(URI uri) { super(uri); diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/InvalidNameException.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/InvalidNameException.java index d3be2ec..5e2b39c 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/InvalidNameException.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/InvalidNameException.java @@ -1,10 +1,15 @@ package ch.zhaw.projekt2.turnierverwaltung; +/** + * Invalid NameException is used to indicate when a given name does not follow the correct formatting. + */ public class InvalidNameException extends Exception { - public InvalidNameException() { - super(); - } - + /** + * Constructor to throw the InvalidNameException, receives a String as input to define reason for throwing + * the error. + * + * @param errorMessage to be displayed with the exception + */ public InvalidNameException(String errorMessage) { super(errorMessage); } diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/IsObservable.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/IsObservable.java index a627e78..9091581 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/IsObservable.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/IsObservable.java @@ -2,18 +2,17 @@ package ch.zhaw.projekt2.turnierverwaltung; /** * Most basic interface for observing an object - * @author bles * + * @author bles */ public interface IsObservable { /** * Add an observer that listens for updates - * @param observer */ void addListener(IsObserver observer); + /** * Remove an observer from the list - * @param observer */ void removeListener(IsObserver observer); } diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/IsObserver.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/IsObserver.java index 4501482..6d174f4 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/IsObserver.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/IsObserver.java @@ -1,11 +1,12 @@ package ch.zhaw.projekt2.turnierverwaltung; /** - * Most basic interface for beeing an observer - * @author bles + * Most basic interface for being an observer * + * @author bles */ public interface IsObserver { + /** * This method is always called when an observed object * changes