You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3.01-QCM_MuscuMaths/WebApi/Model/Player.cs

56 lines
1.7 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public class Player
{
/// <summary>
/// define a player
/// attributes :
/// id : identifier in the database
/// nickname : nickname for the player
/// hashedPassword : hashed of the password of the player
/// </summary>
private int id;
private string? nickname;
private string? hashedPassword;
/// <summary>
/// getters and setters for attributes
/// </summary>
public int? Id
{
get => id == -1 ? null : id;
private set { id = value == null || value < -1 ? -1 : value.Value; }
}
public string Nickname
{
get => nickname == null ? "" : nickname;
private set { nickname = value == "" ? null : nickname; }
}
public string HashedPassword
{
get => hashedPassword == null ? "" : hashedPassword;
set { hashedPassword = value == "" ? null : value; }
}
/// <summary>
/// constructor of a player
/// </summary>
/// <param name="nickname">nickname of the player</param>
/// <param name="hashedPassword">hash of the password of the player</param>
/// <param name="id">id of the player</param>
public Player(string nickname, string hashedPassword = "", int? id = null)
{
Nickname = nickname;
HashedPassword = hashedPassword;
Id = id;
}
}
}