From 7eebbbecb00a67a5c5c9e661012adebd32c32bf3 Mon Sep 17 00:00:00 2001 From: Anthony RICHARD Date: Sat, 29 Apr 2023 09:48:30 +0200 Subject: [PATCH] Modification de la classe User --- Sources/Stim/Stim/User.cs | 52 ++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/Sources/Stim/Stim/User.cs b/Sources/Stim/Stim/User.cs index 8ba6864..0a0802c 100644 --- a/Sources/Stim/Stim/User.cs +++ b/Sources/Stim/Stim/User.cs @@ -3,23 +3,55 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Text.RegularExpressions; namespace Stim { internal class User { static int nbUser=0; - public int Id { get; } - public string Username { get; set; } + private int id; + + public string Username + { + get { return Username; } + private set + { + username = value; + } + } + private string username; + public string Biographie { get; set; } - public string Email { get; set; } - public string Password { get; set; } + + public string Email + { + get { return email; } + private set + { + //check email + email = value; + } + } + private string email; + + public string Password + { + get { return password; } + private set + { + Regex rg = new Regex("^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$"); + if (!rg.IsMatch(password)) return; + password = value; + } + } + private string password; public List Games { get; set; } public User(string username, string biographie, string email, string password) { nbUser++; - Id = nbUser; + id = nbUser; Username = username; Biographie = biographie; @@ -27,15 +59,5 @@ namespace Stim Password = password; Games = new List(); } - - public void AddGame(Game game) - { - Games.Add(game); - } - - public void RemoveGame(Game game) - { - Games.Remove(game); - } } }