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

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

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

Loading…
Cancel
Save