java.lang.Object
edu.ntnu.idatt1002.k01g08.fta.controllers.Admin
Admin class. Used to link GUI controllers with the other class
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
addPlayerToExistingTeam
(String playerName, int number, String teamName) Method for adding a player to an existing teamstatic boolean
addPlayerToNewestTeam
(String name, int number) Method for adding a player to the newest teamstatic boolean
addPlayerToTeam
(String playerName, int number, String teamName) Method for adding a player to a teamstatic void
Method for adding a teamstatic void
Method for changing the contrast-stylestatic void
createTournament
(ArrayList<String> teams) Method for creating a tournamentstatic void
deletePlayer
(String teamName, int playerNumber) Method for deleting a playerstatic void
deleteTeam
(String teamName) Method for deleting a teamstatic void
editPlayer
(String teamName, int oldPlayerNumber, int newPlayerNumber, String playerName) Method for editing a playerstatic void
editTeamName
(String teamName, String newTeamName) Method for editing a teams namestatic Match
Method for retrieving the current active matchstatic String
Method for retrieving the active stylestatic Tournament
Method for retrieving the active tournamentstatic Match
Method for retrieving the current reported matchstatic Match
Method for retrieving the next scheduled matchstatic int
Method for returning the amount of players to createstatic int
Method for retrieving the amount of teams to add to a tournamntgetPlayerStrings
(String teamName) Method for retrieving every player in a teamMethod for retrieving the names of every team in the registerMethod for retrieving the teams when creating a tournamentMethod for retrieving the teams names in a tournamentstatic boolean
Checks if it's high contrast modestatic void
Method for loading the active matchstatic void
Method for loading teams from a filestatic void
Method for loading tournaments from a filestatic boolean
numberOfTeamsInvalid
(int num) Method for determine whether the number of teams is invalidstatic void
Method for saving a team to the registerstatic void
saveTournament
(Tournament tournament) Method for saving a tournamentstatic void
selectActiveTournament
(int n) Method for setting the active tournamentstatic void
setActiveStyle
(String style) Method for setting the active stylestatic void
setCurrentReportedMatch
(int n) Method for setting the current reported matchstatic void
setNumOfTeamsToAdd
(int num) Method for setting the amount of teams to addstatic void
Temporary storage of the tournament name when creating a tournament
-
Constructor Details
-
Admin
public Admin()
-
-
Method Details
-
addTeam
Method for adding a team- Parameters:
teamName
- is the team name as a StringnumOfPlayers
- is the amount of players in the team- Throws:
IllegalArgumentException
- if the team is already existing
-
getNumOfPlayersToCreate
public static int getNumOfPlayersToCreate()Method for returning the amount of players to create- Returns:
- the amount as an int
-
addPlayerToNewestTeam
Method for adding a player to the newest team- Parameters:
name
- is the name of the player as a Stringnumber
- is players shirt number as an int- Returns:
- true or false
-
addPlayerToTeam
Method for adding a player to a team- Parameters:
playerName
- is the players name as a Stringnumber
- is the players shirt number as an intteamName
- is the teams name as a String- Returns:
- true or false
-
addPlayerToExistingTeam
public static boolean addPlayerToExistingTeam(String playerName, int number, String teamName) throws IOException Method for adding a player to an existing team- Parameters:
playerName
- is the players name as a Stringnumber
- is the players shirt number as an intteamName
- is the teams name as a String- Returns:
- true or false
- Throws:
IOException
- if there is an error
-
saveTeams
Method for saving a team to the register- Throws:
IOException
- if there is an error
-
loadTeams
public static void loadTeams()Method for loading teams from a file -
loadTournaments
public static void loadTournaments()Method for loading tournaments from a file -
saveTournament
Method for saving a tournament- Parameters:
tournament
- is the tournament being saved- Throws:
IOException
- if there was an error when saving the tournament
-
getTeamNames
Method for retrieving the names of every team in the register- Returns:
- the team names as an ArrayList
-
getPlayerStrings
Method for retrieving every player in a team- Parameters:
teamName
- is the name of the team as a String- Returns:
- the players in the team as an ArrayList
-
editTeamName
public static void editTeamName(String teamName, String newTeamName) throws IOException, IllegalArgumentException Method for editing a teams name- Parameters:
teamName
- is the current name of the team as a StringnewTeamName
- is the teams new name as a String- Throws:
IOException
- if there was an errorIllegalArgumentException
- if there already is a team with the same name
-
deleteTeam
Method for deleting a team- Parameters:
teamName
- is the name of the team being deleted as a String- Throws:
IOException
- if there was an error when deleting the team
-
editPlayer
public static void editPlayer(String teamName, int oldPlayerNumber, int newPlayerNumber, String playerName) throws IOException Method for editing a player- Parameters:
teamName
- is the name of the team the player plays foroldPlayerNumber
- is the old shirt number of the player as an intnewPlayerNumber
- is the new shirt number of the player as an intplayerName
- is the players name as a String- Throws:
IOException
- if there was an error when editing the player
-
deletePlayer
Method for deleting a player- Parameters:
teamName
- is the name of the team the player plays forplayerNumber
- is the players shirt number as an int- Throws:
IOException
- if there was an error when deleting the player
-
numberOfTeamsInvalid
public static boolean numberOfTeamsInvalid(int num) Method for determine whether the number of teams is invalid- Parameters:
num
- is the amount of teams- Returns:
- true or false
-
setTournamentToCreateName
Temporary storage of the tournament name when creating a tournament- Parameters:
name
- is the temporary name of the tournament
-
setNumOfTeamsToAdd
public static void setNumOfTeamsToAdd(int num) Method for setting the amount of teams to add- Parameters:
num
- is the amount as an int
-
getNumOfTeamsToAdd
public static int getNumOfTeamsToAdd()Method for retrieving the amount of teams to add to a tournamnt- Returns:
- the amount as an int
-
createTournament
Method for creating a tournament- Parameters:
teams
- is the teams in the tournament- Throws:
IOException
- if there was an error when creating the tournament
-
getTeams
Method for retrieving the teams when creating a tournament- Parameters:
teams
- is the list of the teams- Returns:
- the list of teams
-
getTournamentNames
Method for retrieving the teams names in a tournament- Returns:
- the names of teams in a tournament as an ArrayList
-
getActiveTournament
Method for retrieving the active tournament- Returns:
- the tournament
-
getNextMatch
Method for retrieving the next scheduled match- Returns:
- the next match
-
selectActiveTournament
public static void selectActiveTournament(int n) Method for setting the active tournament- Parameters:
n
- is the index of the tournament in the register as an int
-
loadActiveMatch
public static void loadActiveMatch()Method for loading the active match -
setCurrentReportedMatch
public static void setCurrentReportedMatch(int n) Method for setting the current reported match- Parameters:
n
- is the index of the match in the register
-
getCurrentReportedMatch
Method for retrieving the current reported match- Returns:
- the current reported match
-
getActiveMatch
Method for retrieving the current active match- Returns:
- the active match
-
getActiveStyle
Method for retrieving the active style- Returns:
- the active style as a String
-
setActiveStyle
Method for setting the active style- Parameters:
style
- is the new style
-
changeContrast
public static void changeContrast()Method for changing the contrast-style -
isHighContrast
public static boolean isHighContrast()Checks if it's high contrast mode- Returns:
- true if is high contrast mode
-