Record Class GameSessionState
java.lang.Object
java.lang.Record
it.unisa.diem.wordageddon_g16.models.GameSessionState
- Record Components:
user- L'utente a cui appartiene la sessionequestions- Lista delle domande generatedomandaRisposte- Mappa domanda --> risposta data (-1 se saltata)currentQuestionIndex- Indice della domanda attualequestionStartTime- Istante d'inizio delle domande (può essere null se non usato)
- All Implemented Interfaces:
Serializable
public record GameSessionState(User user, List<Question> questions, Map<Question,Integer> domandaRisposte, int currentQuestionIndex, LocalDateTime questionStartTime, int scorePerQuestion, GameParams gameParams)
extends Record
implements Serializable
Rappresenta lo stato temporaneo di una sessione di gioco interrotta in Wordageddon.
Questa record viene serializzato per permettere il salvataggio e il recupero preciso della partita nel punto in cui l'utente ha interrotto.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intThe field for thecurrentQuestionIndexrecord component.The field for thedomandaRisposterecord component.private final GameParamsThe field for thegameParamsrecord component.The field for thequestionsrecord component.private final LocalDateTimeThe field for thequestionStartTimerecord component.private final intThe field for thescorePerQuestionrecord component.private static final longprivate final UserThe field for theuserrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionGameSessionState(User user, List<Question> questions, Map<Question, Integer> domandaRisposte, int currentQuestionIndex, LocalDateTime questionStartTime, int scorePerQuestion, GameParams gameParams) Creates an instance of aGameSessionStaterecord class. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of thecurrentQuestionIndexrecord component.Returns the value of thedomandaRisposterecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thegameParamsrecord component.final inthashCode()Returns a hash code value for this object.Returns the value of thequestionsrecord component.Returns the value of thequestionStartTimerecord component.intReturns the value of thescorePerQuestionrecord component.final StringtoString()Returns a string representation of this record class.user()Returns the value of theuserrecord component.
-
Field Details
-
user
-
questions
-
domandaRisposte
The field for thedomandaRisposterecord component. -
currentQuestionIndex
private final int currentQuestionIndexThe field for thecurrentQuestionIndexrecord component. -
questionStartTime
The field for thequestionStartTimerecord component. -
scorePerQuestion
private final int scorePerQuestionThe field for thescorePerQuestionrecord component. -
gameParams
The field for thegameParamsrecord component. -
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
GameSessionState
public GameSessionState(User user, List<Question> questions, Map<Question, Integer> domandaRisposte, int currentQuestionIndex, LocalDateTime questionStartTime, int scorePerQuestion, GameParams gameParams) Creates an instance of aGameSessionStaterecord class.- Parameters:
user- the value for theuserrecord componentquestions- the value for thequestionsrecord componentdomandaRisposte- the value for thedomandaRisposterecord componentcurrentQuestionIndex- the value for thecurrentQuestionIndexrecord componentquestionStartTime- the value for thequestionStartTimerecord componentscorePerQuestion- the value for thescorePerQuestionrecord componentgameParams- the value for thegameParamsrecord component
-
-
Method Details
-
user
-
questions
-
domandaRisposte
Returns the value of thedomandaRisposterecord component.- Returns:
- the value of the
domandaRisposterecord component
-
currentQuestionIndex
public int currentQuestionIndex()Returns the value of thecurrentQuestionIndexrecord component.- Returns:
- the value of the
currentQuestionIndexrecord component
-
questionStartTime
Returns the value of thequestionStartTimerecord component.- Returns:
- the value of the
questionStartTimerecord component
-
scorePerQuestion
public int scorePerQuestion()Returns the value of thescorePerQuestionrecord component.- Returns:
- the value of the
scorePerQuestionrecord component
-
gameParams
Returns the value of thegameParamsrecord component.- Returns:
- the value of the
gameParamsrecord component
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes.
-