perf : modification des classes
continuous-integration/drone/push Build is passing Details

API
Damien NORTIER 1 year ago
parent a8a3b0f42e
commit fd140081ad

@ -9,14 +9,12 @@ namespace Model
/// id : identifier in the database
/// content : content of the answer
/// idQuestion : the id of the question which it answer to
/// question : the question which it answer to
/// </summary>
public class Answer
{
private uint id;
private string? content;
private uint idQuestion;
public Question? question;
private uint? idQuestion;
// getters and setters for attributes
public uint Id
@ -29,28 +27,23 @@ namespace Model
get => content == null ? "" : content;
set { content = value == "" ? null : value; }
}
public uint IdQuestion
public uint? IdQuestion
{
get => idQuestion; // null = no idQuestion
private set { idQuestion = value; }
set { idQuestion = value; }
}
public Question? Question
{
get => question;
private set { question = value; IdQuestion = value == null ? 0 : value.Id; }
}
/// <summary>
/// constructor of an answer
/// </summary>
/// <param name="content">the content of the answer</param>
/// <param name="idQuestion">the id of the question which it answer to</param>
/// <param name="id">the id in the database</param>
/// <param name="question">the question which it answer to</param>
public Answer(string content, Question? question = null, uint id = 0)
public Answer(string content, uint? idQuestion = null, uint id = 0)
{
Content = content;
IdQuestion = idQuestion;
Id = id;
Question = question;
}
}

@ -15,7 +15,6 @@ namespace Model
/// name : name of the lobby
/// password : password require to access at the lobby
/// idCreator : identifier of the creator player
/// creator : the creator player
/// </summary>
public class Lobby
{
@ -24,7 +23,6 @@ namespace Model
private string? password;
private uint nbPlayers;
private uint? idCreator;
private Player creator;
// getters and setters of attributes
public uint Id
{
@ -51,11 +49,6 @@ namespace Model
get => idCreator;
private set { idCreator = value; }
}
public Player Creator
{
get => creator;
set { creator = value; idCreator = value.Id; }
}
/// <summary>
/// constructor of a lobby
@ -63,12 +56,12 @@ namespace Model
/// <param name="name">the name of the lobby</param>
/// <param name="creator">the creator</param>
/// <param name="password">the password require to access to the lobby</param>
/// <param name="nbPlayer">the number of players in the lobby</param>
/// <param name="nbPlayers">the number of players in the lobby</param>
/// <param name="id">the id of the lobby</param>
public Lobby(string name, Player creator, string password = "", uint nbPlayers = 0, uint id = 0)
public Lobby(string name, uint? idCreator, string password = "", uint nbPlayers = 0, uint id = 0)
{
Name = name;
Creator = creator;
IdCreator = idCreator;
Password = password;
NbPlayers = nbPlayers;
Id = id;

@ -17,8 +17,6 @@ namespace Model
/// nbFails : number of time that people fail on this question
/// idChapter : identifier of the chapter of the question
/// idAnswerGood : identifier of the right answer to this question
/// chapter : the chapter of the question
/// answerGood : the right answer to this question
/// </summary>
public class Question
{
@ -27,9 +25,7 @@ namespace Model
private byte difficulty;
private uint nbFalls;
private uint idChapter;
private uint idAnswerGood;
private Chapter? chapter;
private Answer? answerGood;
private uint? idAnswerGood;
public uint Id
{
@ -56,32 +52,20 @@ namespace Model
get => idChapter;
private set { idChapter = value; }
}
public uint IdAnswerGood
public uint? IdAnswerGood
{
get => idAnswerGood;
set { idAnswerGood = value; }
}
public Chapter? Chapter
{
get => chapter;
set { chapter = value; IdChapter = value == null ? 0 : value.Id; }
}
public Answer? AnswerGood
{
get => answerGood;
set { answerGood = value; IdAnswerGood = value == null ? 0 : value.Id; }
}
public Question(string content, Chapter? chapter = null, uint id = 0, Answer? answerGood = null)
public Question(string content, uint idChapter, uint id = 0, uint? idAnswerGood = null)
{
Id = id;
Content = content;
Difficulty = 1;
NbFalls = 0;
Chapter = chapter;
AnswerGood = answerGood;
IdChapter = idChapter;
IdAnswerGood = idAnswerGood;
}
}
}

Loading…
Cancel
Save