Record Class GameReport

java.lang.Object
java.lang.Record
it.unisa.diem.wordageddon_g16.models.GameReport
Record Components:
user - utente che ha effettuato la sessione
documents - lista dei documenti selezionati per la partita
timestamp - data e ora di fine sessione di gioco
difficulty - livello di difficoltà della sessione
maxTime - tempo massimo previsto per rispondere alle domande
usedTime - tempo effettivamente impiegato nel rispondere alle domande
questionCount - numero totale di domande generate
score - punteggio ottenuto alla fine della sessione

public record GameReport(User user, List<Document> documents, LocalDateTime timestamp, Difficulty difficulty, Duration maxTime, Duration usedTime, int questionCount, int score) extends Record
Rappresenta un report di una sessione di gioco nell'applicazione Wordageddon.

Include informazioni sul giocatore, i documenti utilizzati, la difficoltà selezionata, il tempo impiegato, il numero di domande e il punteggio ottenuto. Viene utilizzato per memorizzare i risultati delle partite completate.

  • Field Details

    • user

      private final User user
      The field for the user record component.
    • documents

      private final List<Document> documents
      The field for the documents record component.
    • timestamp

      private final LocalDateTime timestamp
      The field for the timestamp record component.
    • difficulty

      private final Difficulty difficulty
      The field for the difficulty record component.
    • maxTime

      private final Duration maxTime
      The field for the maxTime record component.
    • usedTime

      private final Duration usedTime
      The field for the usedTime record component.
    • questionCount

      private final int questionCount
      The field for the questionCount record component.
    • score

      private final int score
      The field for the score record component.
  • Constructor Details

    • GameReport

      public GameReport(User user, List<Document> documents, LocalDateTime timestamp, Difficulty difficulty, Duration maxTime, Duration usedTime, int questionCount, int score)
      Costruttore compatto per il record GameReport.

      Se la lista dei documenti è null, viene inizializzata come lista vuota per evitare NullPointerException in fasi successive.

  • Method Details

    • user

      public User user()
      Restituisce l’utente che ha giocato la partita.
      Returns:
      istanza di User associata alla sessione
    • documents

      public List<Document> documents()
      Restituisce la lista dei documenti utilizzati nella sessione.
      Returns:
      lista di Document
    • timestamp

      public LocalDateTime timestamp()
      Restituisce la data e ora di avvio della sessione di gioco.
      Returns:
      istanza di LocalDateTime
    • difficulty

      public Difficulty difficulty()
      Restituisce il livello di difficoltà selezionato per la partita.
      Returns:
      valore di Difficulty
    • maxTime

      public Duration maxTime()
      Restituisce il tempo massimo concesso per la sessione di gioco, ossia il tempo per rispondere alle domande.
      Returns:
      tempo massimo come Duration
    • usedTime

      public Duration usedTime()
      Restituisce il tempo effettivamente impiegato dal giocatore nel rispondere alle domande.
      Returns:
      tempo utilizzato come Duration
    • questionCount

      public int questionCount()
      Restituisce il numero totale di domande generate nella sessione.
      Returns:
      numero di domande
    • score

      public int score()
      Restituisce il punteggio ottenuto dal giocatore durante la sessione.
      Returns:
      punteggio finale
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.