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
    Confrontation getConfrontation​(int index)
    Get the Confrontation at the index position of the list
    java.util.List<Confrontation> getConfrontations()
    Give the fight's tournament list
    int getNbTours()
    Return the number of round for each fight in the tournament
    IStrategie getStrategie​(int index)
    Give the opponent saved at the index position of the list
    java.util.List<IStrategie> getStrategies()
    Give all the opponent
    boolean hasMoreElements()
    Allows to know if the tournament still have fight
    Confrontation nextElement()
    Launch the next fight of the tournament and give a sum up of this last at the end
    void setNbTours​(int nbTours)
    Set the number of round for the tournament
    void setStrategies​(java.util.List<IStrategie> strategies)
    Set the different opponent and theirs fights too
    java.lang.String toString()
    Return the confrontation of the tournament

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.util.Enumeration

    asIterator
  • Constructor Details

    • Tournoi

      public Tournoi​(int nbTours, java.util.List<IStrategie> strategies) throws java.lang.NullPointerException, java.lang.Exception
      Constructs 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 round
      strategies - The list of participant
      Throws:
      java.lang.Exception - If the user doesn't give at least one Strategie
      java.lang.NullPointerException
      See Also:
      IStrategie, List
  • Method Details

    • hasMoreElements

      public boolean hasMoreElements()
      Allows to know if the tournament still have fight
      Specified by:
      hasMoreElements in interface java.util.Enumeration<Confrontation>
      Returns:
      boolean Says if the tournament continues
      See Also:
      Enumeration.hasMoreElements()
    • nextElement

      public Confrontation nextElement()
      Launch the next fight of the tournament and give a sum up of this last at the end
      Specified by:
      nextElement in interface java.util.Enumeration<Confrontation>
      Returns:
      String The sum up of the fight
      See Also:
      java.util.Enumaration#nextElement()
    • getConfrontations

      public java.util.List<Confrontation> getConfrontations()
      Give the fight's tournament list
      Returns:
      ArrayList The list of fight
      See Also:
      Confrontation(IStrategie, IStrategie)
    • getConfrontation

      public Confrontation getConfrontation​(int index)
      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

      public java.util.List<IStrategie> getStrategies()
      Give all the opponent
      Returns:
      List All the opponent of the tournament
      See Also:
      IStrategie, List
    • getStrategie

      public IStrategie getStrategie​(int index)
      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

      public void setStrategies​(java.util.List<IStrategie> strategies) throws java.lang.Exception
      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:
      toString in class java.lang.Object
      Returns:
      String which contains the number of fight and round, the different opponent and fight
      See Also:
      Object.toString()