diff --git a/src/main/java/com/r0r5chach/CompetitorList.java b/src/main/java/com/r0r5chach/CompetitorList.java index 5cbe57b..ada4b00 100644 --- a/src/main/java/com/r0r5chach/CompetitorList.java +++ b/src/main/java/com/r0r5chach/CompetitorList.java @@ -19,8 +19,6 @@ import com.r0r5chach.competitor.r6.R6Defender; import com.r0r5chach.competitor.r6.R6Player; import com.r0r5chach.competitor.valorant.ValorantAgent; import com.r0r5chach.competitor.valorant.ValorantPlayer; - - public class CompetitorList { private final ArrayList competitors; private String reportContents; diff --git a/src/main/java/com/r0r5chach/Manager.java b/src/main/java/com/r0r5chach/Manager.java index f29c5f8..dc5689b 100644 --- a/src/main/java/com/r0r5chach/Manager.java +++ b/src/main/java/com/r0r5chach/Manager.java @@ -93,7 +93,7 @@ public class Manager extends Application { competitors.readCompetitors(r6Players); } catch (Exception e) { - createErrorLog(e, "src/main/resources/log.txt"); + createErrorLog(e, "src/main/resources/com/r0r5chach/log.txt"); } return competitors; } diff --git a/src/main/java/com/r0r5chach/competitor/Competitor.java b/src/main/java/com/r0r5chach/competitor/Competitor.java index a61735b..e994d21 100644 --- a/src/main/java/com/r0r5chach/competitor/Competitor.java +++ b/src/main/java/com/r0r5chach/competitor/Competitor.java @@ -2,7 +2,7 @@ package com.r0r5chach.competitor; import java.text.DecimalFormat; /** - * Class that defines the various attributes and methods associated with a Valorant Player + * Class that defines the various attributes and methods associated with a Competitor * @author r0r5chach */ public abstract class Competitor { @@ -32,6 +32,7 @@ public abstract class Competitor { * @param playerNumber the number of the player * @param playerName the name of the player * @param playerLevel the level of the player + * @param scores an array containing the 6 scores the player has achieved */ public Competitor(int playerNumber, Name playerName, Rank playerLevel, int[] scores) { this.playerNumber = playerNumber; @@ -123,4 +124,4 @@ public abstract class Competitor { public String getShortDetails() { return "CN " + getPlayerNumber() + " (" + getPlayerName().getInitials() + ") has overall score " + getOverallScore(); } -} +} \ No newline at end of file diff --git a/src/main/java/com/r0r5chach/competitor/Name.java b/src/main/java/com/r0r5chach/competitor/Name.java index 1b2db32..401e6d3 100644 --- a/src/main/java/com/r0r5chach/competitor/Name.java +++ b/src/main/java/com/r0r5chach/competitor/Name.java @@ -2,7 +2,7 @@ package com.r0r5chach.competitor; /** * Class that defines a name and it's parts - * @author John.Kanyaru@northampton.ac.uk + * @author r0r5chach */ public class Name { /** @@ -127,5 +127,4 @@ public class Name { result += lastName.substring(0,1); return result; } -} - +} \ No newline at end of file diff --git a/src/main/java/com/r0r5chach/competitor/Rank.java b/src/main/java/com/r0r5chach/competitor/Rank.java index ffc2be7..62f43f6 100644 --- a/src/main/java/com/r0r5chach/competitor/Rank.java +++ b/src/main/java/com/r0r5chach/competitor/Rank.java @@ -1,17 +1,18 @@ package com.r0r5chach.competitor; import java.util.Locale; - /** * All levels a ValorantPlayer can be * @author r0r5chach */ public enum Rank { /** - * First Level + * For ChoiceBoxes so selection is not null */ NONE, - + /** + * First Level + */ BRONZE, /** * Second Level @@ -32,4 +33,4 @@ public enum Rank { public String getRank() { return this.name().charAt(0) + this.name().substring(1).toLowerCase(Locale.ROOT); //Capitalizes the first letter and makes sure the other letters are lowercase } -} +} \ No newline at end of file diff --git a/src/main/java/com/r0r5chach/competitor/r6/R6Attacker.java b/src/main/java/com/r0r5chach/competitor/r6/R6Attacker.java index 53b2a9c..23efba2 100644 --- a/src/main/java/com/r0r5chach/competitor/r6/R6Attacker.java +++ b/src/main/java/com/r0r5chach/competitor/r6/R6Attacker.java @@ -1,8 +1,13 @@ package com.r0r5chach.competitor.r6; import java.util.Locale; - +/** All Attackers an R6Player can play +* @author r0r5chach +*/ public enum R6Attacker { + /** + * For ChoiceBoxes so selection is not null + */ NONE, GRIM, SENS, @@ -37,8 +42,11 @@ public enum R6Attacker { IQ, FUZE, GLAZ; - + /** + * Get the name of the attacker + * @return the name of the attacker as a formatted string + */ public String getAttacker() { return this.name().charAt(0) + this.name().substring(1).toLowerCase(Locale.ROOT); //Capitalizes the first letter and makes sure the other letters are lowercase } -} +} \ No newline at end of file diff --git a/src/main/java/com/r0r5chach/competitor/r6/R6Defender.java b/src/main/java/com/r0r5chach/competitor/r6/R6Defender.java index a50f3f4..78fa7e5 100644 --- a/src/main/java/com/r0r5chach/competitor/r6/R6Defender.java +++ b/src/main/java/com/r0r5chach/competitor/r6/R6Defender.java @@ -1,8 +1,13 @@ package com.r0r5chach.competitor.r6; import java.util.Locale; - +/** All Defenders an R6Player can play +* @author r0r5chach +*/ public enum R6Defender { + /** + * For ChoiceBoxes so selection is not null + */ NONE, SOLIS, AZAMI, @@ -37,8 +42,11 @@ public enum R6Defender { BANDIT, TACHANKA, KAPKAN; - + /** + * Get the name of the defender + * @return the name of the defender as a formatted string + */ public String getDefender() { return this.name().charAt(0) + this.name().substring(1).toLowerCase(Locale.ROOT); //Capitalizes the first letter and makes sure the other letters are lowercase } -} +} \ No newline at end of file diff --git a/src/main/java/com/r0r5chach/competitor/r6/R6Player.java b/src/main/java/com/r0r5chach/competitor/r6/R6Player.java index 5dc535a..ab001fe 100644 --- a/src/main/java/com/r0r5chach/competitor/r6/R6Player.java +++ b/src/main/java/com/r0r5chach/competitor/r6/R6Player.java @@ -5,33 +5,66 @@ import java.util.Arrays; import com.r0r5chach.competitor.Competitor; import com.r0r5chach.competitor.Name; import com.r0r5chach.competitor.Rank; - +/** + * Class that defines the various attributes and methods associated with a R6 Player + * Inherits from the com.r0r5chach.competitor.Competitor Class + * @author r0r5chach + */ public class R6Player extends Competitor{ + /** + * Attribute that stores the player's favorite Attacker + */ private R6Attacker favoriteAttacker; + /** + * Attribute that stores the player's favorite Defender + */ private R6Defender favoriteDefender; - + /** + * Constructs an R6Player object with attributes matching the parameters passed + * @param playerNumber the number of the player + * @param playerName the name of the player + * @param playerLevel the level of the player + * @param favoriteAttacker the attacker the player plays most + * @param favoriteDefender the defender the player plays most + * @param scores an array containing the 6 scores the player has achieved + */ public R6Player(int playerNumber, Name playerName, Rank playerLevel, R6Attacker favoriteAttacker, R6Defender favoriteDefender, int[] scores) { super(playerNumber, playerName, playerLevel, scores); this.favoriteAttacker = favoriteAttacker; this.favoriteDefender = favoriteDefender; } - + /** + * Set the player's most played attacker to that of the parameter + * @param favoriteAttacker the new most played attacker of the player + */ public void setFavoriteAttacker(R6Attacker favoriteAttacker) { this.favoriteAttacker = favoriteAttacker; } - + /** + * Set the player's most played defender to that of the parameter + * @param favoriteDefender the new most played defender of the player + */ public void setFavoriteDefender(R6Defender favoriteDefender) { this.favoriteDefender = favoriteDefender; } - + /** + * Get the player's most played attacker + * @return the player's most played attack + */ public R6Attacker getFavoriteAttacker() { return this.favoriteAttacker; } - + /** + * Get the player's most played defender + * @return the player's most played defender + */ public R6Defender getFavoriteDefender() { return this.favoriteDefender; } - + /** + * Get all the attributes of the player + * @return all attributes of the player in a formatted string + */ public String getFullDetails() { return "Player Number: " + getPlayerNumber() + "\nName: " + getPlayerName().getFullName() + @@ -41,4 +74,4 @@ public class R6Player extends Competitor{ "\nFavorite Attacker: " + getFavoriteAttacker().getAttacker() + "\nFavorite Defender: " + getFavoriteDefender().getDefender(); } -} +} \ No newline at end of file diff --git a/src/main/java/com/r0r5chach/competitor/valorant/ValorantAgent.java b/src/main/java/com/r0r5chach/competitor/valorant/ValorantAgent.java index 1bc3e3e..09cb837 100644 --- a/src/main/java/com/r0r5chach/competitor/valorant/ValorantAgent.java +++ b/src/main/java/com/r0r5chach/competitor/valorant/ValorantAgent.java @@ -1,12 +1,14 @@ package com.r0r5chach.competitor.valorant; import java.util.Locale; - /** * All Characters a ValorantPlayer can play * @author r0r5chach */ public enum ValorantAgent { + /** + * For ChoiceBoxes so selection is not null + */ NONE, BRIMSTONE, VIPER, @@ -30,9 +32,9 @@ public enum ValorantAgent { HARBOR; /** * Get the name of the character - * @return a formatted string containing the character name + * @return the name of the character as a formatted string */ public String getAgent() { return this.name().charAt(0) + this.name().substring(1).toLowerCase(Locale.ROOT); //Capitalizes the first letter and makes sure the other letters are lowercase } -} +} \ No newline at end of file diff --git a/src/main/java/com/r0r5chach/competitor/valorant/ValorantPlayer.java b/src/main/java/com/r0r5chach/competitor/valorant/ValorantPlayer.java index c1ef216..e980539 100644 --- a/src/main/java/com/r0r5chach/competitor/valorant/ValorantPlayer.java +++ b/src/main/java/com/r0r5chach/competitor/valorant/ValorantPlayer.java @@ -7,9 +7,13 @@ import com.r0r5chach.competitor.Name; import com.r0r5chach.competitor.Rank; /** * Class that defines the various attributes and methods associated with a Valorant Player + * Inherits from the com.r0r5chach.competitor.Competitor Class * @author r0r5chach */ public class ValorantPlayer extends Competitor { + /** + * Attribute that stores the player's favorite character to play + */ private ValorantAgent favoriteAgent; /** * Constructs an object with attributes matching the parameters passed @@ -17,6 +21,7 @@ public class ValorantPlayer extends Competitor { * @param playerName the name of the player * @param playerLevel the level of the player * @param favoriteAgent the character the player plays most + * @param scores an array containing the 6 scores the player has achieved */ public ValorantPlayer(int playerNumber, Name playerName, Rank playerLevel, ValorantAgent favoriteAgent, int[] scores) { super(playerNumber, playerName, playerLevel, scores); @@ -48,4 +53,4 @@ public class ValorantPlayer extends Competitor { "\nOverall Score: " + getOverallScore() + "\nFavorite Agent: " + getFavoriteAgent().getAgent(); } -} +} \ No newline at end of file diff --git a/src/main/java/com/r0r5chach/controllers/Controller.java b/src/main/java/com/r0r5chach/controllers/Controller.java index be6775b..9e2e97b 100644 --- a/src/main/java/com/r0r5chach/controllers/Controller.java +++ b/src/main/java/com/r0r5chach/controllers/Controller.java @@ -5,6 +5,7 @@ import java.net.URL; import java.util.ArrayList; import java.util.ResourceBundle; +import static com.r0r5chach.CompetitorList.createErrorLog; import com.r0r5chach.CompetitorList; import com.r0r5chach.Manager; import com.r0r5chach.competitor.Competitor; @@ -15,55 +16,76 @@ import javafx.fxml.Initializable; import javafx.scene.Parent; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; -import javafx.scene.layout.AnchorPane; - +/** + * Class that defines a generic controller for the GUI + * Inherits from javafx.fxml.Initializable + */ public class Controller implements Initializable { - @FXML - protected AnchorPane editTab; - - @FXML - protected AnchorPane viewTab; - - @FXML - protected AnchorPane reportTab; - + /** + * Attribute that stores the Main Pane for the GUI view + */ @FXML protected TabPane tabs; - + /** + * Attribute that stores the competitor list used by the program + */ protected CompetitorList competitors; + /** + * Attribute that stores the playerNumber of each competitor in the same order as the competitors list to allow easy indexing of competitors list + */ protected ArrayList competitorIds; - + /** + * Method that runs when the program initializes the GUI view + * (param details copied from super implementation) + * @param url The location used to resolve relative paths for the root object + * @param rb The resources used to localize the root object + */ @Override - public void initialize(URL location, ResourceBundle resources) { + public void initialize(URL url, ResourceBundle rb) { Platform.runLater(() -> { loadCompetitors(); }); } - + /** + * Sets the controller's competitor list to that of the new parameter + * @param competitors the new competitor list + */ public void setCompetitors(CompetitorList competitors) { this.competitors = competitors; } - + /** + * Gets the controller's competitor list + * @return the controller's competitor list + */ public CompetitorList getCompetitors() { return competitors; } - + /** + * Gets the tab selected on the GUI + */ @FXML - protected void getTab() throws IOException { + protected void getTab() { Parent root = null; Tab tab = tabs.getSelectionModel().getSelectedItem(); - switch(tab.getText().toLowerCase()) { - case "view" -> root = Manager.loadFXML("pages/view"); - case "edit" -> root = Manager.loadFXML("pages/edit"); - case "report" -> root = Manager.loadFXML("pages/report"); + try { + switch(tab.getText().toLowerCase()) { + case "view" -> root = Manager.loadFXML("pages/view"); + case "edit" -> root = Manager.loadFXML("pages/edit"); + case "report" -> root = Manager.loadFXML("pages/report"); + } + } + catch (IOException e) { + createErrorLog(e, "src/main/resources/com/r0r5chach/log.txt"); } tab.setContent(root); } - + /** + * Initializes the competitorIds array for the controller + */ protected void loadCompetitors(){ competitorIds = new ArrayList(); for (Competitor player : competitors.getCompetitors()) { competitorIds.add(player.getPlayerNumber()); } } -} +} \ No newline at end of file diff --git a/src/main/java/com/r0r5chach/controllers/EditController.java b/src/main/java/com/r0r5chach/controllers/EditController.java index b87afd4..f3cc04a 100644 --- a/src/main/java/com/r0r5chach/controllers/EditController.java +++ b/src/main/java/com/r0r5chach/controllers/EditController.java @@ -21,8 +21,10 @@ import javafx.scene.control.ChoiceBox; import javafx.scene.control.ListView; import javafx.scene.control.TextField; import javafx.scene.text.Text; - - +/** + * Class that defines the controller for the edit View (edit.fxml) of the GUI + * Inherits from com.r0r5chach.controllers.Controller + */ public class EditController extends Controller { @FXML diff --git a/src/main/java/com/r0r5chach/controllers/FiltersController.java b/src/main/java/com/r0r5chach/controllers/FiltersController.java index db5e603..6169ac0 100644 --- a/src/main/java/com/r0r5chach/controllers/FiltersController.java +++ b/src/main/java/com/r0r5chach/controllers/FiltersController.java @@ -17,7 +17,10 @@ import javafx.scene.control.TextArea; import javafx.scene.control.TextField; import javafx.scene.control.ToggleGroup; import javafx.scene.control.RadioButton; - +/** + * Class that defines the controller for the filters View (filters.fxml) of the GUI + * Inherits from com.r0r5chach.controllers.Controller + */ public class FiltersController implements Initializable { @FXML private TextField numberFilter; diff --git a/src/main/java/com/r0r5chach/controllers/MainController.java b/src/main/java/com/r0r5chach/controllers/MainController.java index 947a35f..c39fd76 100644 --- a/src/main/java/com/r0r5chach/controllers/MainController.java +++ b/src/main/java/com/r0r5chach/controllers/MainController.java @@ -1,5 +1,8 @@ package com.r0r5chach.controllers; - +/** + * Class that defines the controller for the main View (main.fxml) of the GUI + * Inherits from com.r0r5chach.controllers.Controller + */ public class MainController extends Controller { } \ No newline at end of file diff --git a/src/main/java/com/r0r5chach/controllers/ReportController.java b/src/main/java/com/r0r5chach/controllers/ReportController.java index 1960d20..029a025 100644 --- a/src/main/java/com/r0r5chach/controllers/ReportController.java +++ b/src/main/java/com/r0r5chach/controllers/ReportController.java @@ -8,7 +8,10 @@ import javafx.collections.FXCollections; import javafx.fxml.FXML; import javafx.scene.control.ListView; import javafx.scene.control.TextArea; - +/** + * Class that defines the controller for the report View of the GUI + * Inherits from com.r0r5chach.controllers.Controller + */ public class ReportController extends Controller { @FXML private ListView competitorList; diff --git a/src/main/java/com/r0r5chach/controllers/ViewController.java b/src/main/java/com/r0r5chach/controllers/ViewController.java index acdd237..768d7de 100644 --- a/src/main/java/com/r0r5chach/controllers/ViewController.java +++ b/src/main/java/com/r0r5chach/controllers/ViewController.java @@ -27,7 +27,10 @@ import javafx.scene.control.TableView; import javafx.scene.control.TextArea; import javafx.scene.control.cell.PropertyValueFactory; import javafx.stage.Popup; - +/** + * Class that defines the Controller for the view View (view.fxml) of the GUI + * Inherits from com.r0r5chach.controllers.Controller + */ public class ViewController extends Controller { @FXML private TableView competitorTable;