using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Model
{
    /// <summary>
    /// represent a mathematical question
    /// attributes :
    ///     id : identifier of the question in the database
    ///     content : the content of the question
    ///     difficulty : difficulty (between 1 and 3 included) of the question
    ///     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
    /// </summary>
    public class Question
    {
        private int id;
        private string? content;
        private byte difficulty;
        private int nbFalls;
        private int idChapter;
        private int? idAnswerGood;

        public int Id
        {
            get => id;
            private set { id = value; }
        }
        public string Content
        {
            get => content == null ? "" : content;
            set { content = value == "" ? null : value;}
        }
        public byte Difficulty
        {
            get => difficulty;
            set { difficulty = value; }
        }
        public int NbFalls
        {
            get => nbFalls;
            set { nbFalls = value; }
        }
        public int IdChapter
        {
            get => idChapter;
            private set { idChapter = value; }
        }
        public int? IdAnswerGood
        {
            get => idAnswerGood;
            set { idAnswerGood = value; }
        }

        public Question(string content, int idChapter, int id = 0, int? idAnswerGood = null)
        {
            Id = id;
            Content = content;
            Difficulty = 1;
            NbFalls = 0;
            IdChapter = idChapter;
            IdAnswerGood = idAnswerGood;
        }
    }
}
