Package fr.uga.miage.pc.dilemme.back
Class Tournoi
java.lang.Object
fr.uga.miage.pc.dilemme.back.Tournoi
- All Implemented Interfaces:
java.util.Enumeration<Confrontation>
public class Tournoi extends java.lang.Object implements java.util.Enumeration<Confrontation>
This class allows to construct a object tournament. It can be use in order to launch different fight between two opponent
or more which implement
IStrategie interface.
This class was created for an french university project- Since:
- 1.0
- See Also:
Enumeration,Confrontation,IStrategie
-
Constructor Summary
Constructors Constructor Description Tournoi(int nbTours, java.util.List<IStrategie> strategies)Constructs a tournament with the number of round for the fight and a participant's list. -
Method Summary
Modifier and Type Method Description ConfrontationgetConfrontation(int index)Get the Confrontation at the index position of the listjava.util.List<Confrontation>getConfrontations()Give the fight's tournament listintgetNbTours()Return the number of round for each fight in the tournamentIStrategiegetStrategie(int index)Give the opponent saved at the index position of the listjava.util.List<IStrategie>getStrategies()Give all the opponentbooleanhasMoreElements()Allows to know if the tournament still have fightConfrontationnextElement()Launch the next fight of the tournament and give a sum up of this last at the endvoidsetNbTours(int nbTours)Set the number of round for the tournamentvoidsetStrategies(java.util.List<IStrategie> strategies)Set the different opponent and theirs fights toojava.lang.StringtoString()Return the confrontation of the tournament
-
Constructor Details
-
Tournoi
public Tournoi(int nbTours, java.util.List<IStrategie> strategies) throws java.lang.NullPointerException, java.lang.ExceptionConstructs a tournament with the number of round for the fight and a participant's list. Declare a Exception if the list is null or the size equals zero- Parameters:
nbTours- The number of roundstrategies- The list of participant- Throws:
java.lang.Exception- If the user doesn't give at least one Strategiejava.lang.NullPointerException- See Also:
IStrategie,List
-
-
Method Details
-
hasMoreElements
public boolean hasMoreElements()Allows to know if the tournament still have fight- Specified by:
hasMoreElementsin interfacejava.util.Enumeration<Confrontation>- Returns:
- boolean Says if the tournament continues
- See Also:
Enumeration.hasMoreElements()
-
nextElement
Launch the next fight of the tournament and give a sum up of this last at the end- Specified by:
nextElementin interfacejava.util.Enumeration<Confrontation>- Returns:
- String The sum up of the fight
- See Also:
java.util.Enumaration#nextElement()
-
getConfrontations
Give the fight's tournament list- Returns:
- ArrayList The list of fight
- See Also:
Confrontation(IStrategie, IStrategie)
-
getConfrontation
Get the Confrontation at the index position of the list- Parameters:
index- Position in the list- Returns:
- Confrontation the fight number index
- See Also:
Confrontation(IStrategie, IStrategie)
-
getStrategies
Give all the opponent- Returns:
- List All the opponent of the tournament
- See Also:
IStrategie,List
-
getStrategie
Give the opponent saved at the index position of the list- Parameters:
index- Position in the list- Returns:
- IStrategie The opponent number index
- See Also:
IStrategie
-
setStrategies
Set the different opponent and theirs fights too- Parameters:
strategies- Opponent of the tournament- Throws:
java.lang.Exception- See Also:
Confrontation(IStrategie, IStrategie),IStrategie
-
getNbTours
public int getNbTours()Return the number of round for each fight in the tournament- Returns:
- int The number of round for a fight
-
setNbTours
public void setNbTours(int nbTours)Set the number of round for the tournament- Parameters:
nbTours- The number of round for a fight
-
toString
public java.lang.String toString()Return the confrontation of the tournament- Overrides:
toStringin classjava.lang.Object- Returns:
- String which contains the number of fight and round, the different opponent and fight
- See Also:
Object.toString()
-