From 756764f8ce8cecc2c75537d8a86854f86b9224cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20LAVERGNE?= Date: Sun, 2 Jun 2024 16:44:17 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Traduction=20de=20propri=C3=A9t?= =?UTF-8?q?=C3=A9s=20pour=20les=20d=C3=A9s=20et=20traduction=20des=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/Trek-12/Models/Game/Dice.cs | 28 ++++++++++++++-------------- source/Trek-12/Tests/DiceTests.cs | 14 +++++++------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/source/Trek-12/Models/Game/Dice.cs b/source/Trek-12/Models/Game/Dice.cs index 2d47fe3..36bfd33 100644 --- a/source/Trek-12/Models/Game/Dice.cs +++ b/source/Trek-12/Models/Game/Dice.cs @@ -14,12 +14,12 @@ namespace Models.Game /// /// Lowest number on the dice. /// - public int NbMin { get; private set; } + public int MinVal { get; private set; } /// /// Highest number on the dice. /// - public int NbMax { get; private set; } + public int MaxVal { get; private set; } /// /// Value of the dice. @@ -29,9 +29,9 @@ namespace Models.Game get => _value; private set { - if (value < NbMin || value > NbMax) + if (value < MinVal || value > MaxVal) { - value = NbMin; + value = MinVal; } _value = value; } @@ -40,13 +40,13 @@ namespace Models.Game /// /// Initializes a new instance of the class. /// - /// The lowest number on the dice, on which the highest number is set - public Dice(int nbmin) + /// The lowest number on the dice, on which the highest number is set + public Dice(int minval) { - if (nbmin < 0) nbmin = 0; - if (nbmin > 1) nbmin = 1; - NbMin = nbmin; - NbMax = nbmin + 5; + if (minval < 0) minval = 0; + if (minval > 1) minval = 1; + MinVal = minval; + MaxVal = minval + 5; } /// @@ -54,13 +54,13 @@ namespace Models.Game /// public Dice() { - NbMin = 0; - NbMax = 5; + MinVal = 0; + MaxVal = 5; } public override string ToString() { - return $"Ce dé a pour valeur {Value} et est entre {NbMin} et {NbMax}"; + return $"Ce dé a pour valeur {Value} et est entre {MinVal} et {MaxVal}"; } /// @@ -68,7 +68,7 @@ namespace Models.Game /// public void Roll() { - Value = new Random().Next(NbMin, NbMax + 1); + Value = new Random().Next(MinVal, MaxVal + 1); } /// diff --git a/source/Trek-12/Tests/DiceTests.cs b/source/Trek-12/Tests/DiceTests.cs index 7831db6..22ded18 100644 --- a/source/Trek-12/Tests/DiceTests.cs +++ b/source/Trek-12/Tests/DiceTests.cs @@ -13,30 +13,30 @@ public class DiceTests public void Constructor_WithNegativeNbMin_SetsNbMinToZero() { Dice dice = new Dice(-1); - Assert.Equal(0, dice.NbMin); + Assert.Equal(0, dice.MinVal); } [Fact] public void Constructor_WithNbMinGreaterThanOne_SetsNbMinToOne() { Dice dice = new Dice(2); - Assert.Equal(1, dice.NbMin); + Assert.Equal(1, dice.MinVal); } [Fact] public void Constructor_WithValidNbMin_SetsNbMinAndNbMaxCorrectly() { Dice dice = new Dice(1); - Assert.Equal(1, dice.NbMin); - Assert.Equal(6, dice.NbMax); + Assert.Equal(1, dice.MinVal); + Assert.Equal(6, dice.MaxVal); } [Fact] public void DefaultConstructor_SetsNbMinToZeroAndNbMaxToFive() { Dice dice = new Dice(); - Assert.Equal(0, dice.NbMin); - Assert.Equal(5, dice.NbMax); + Assert.Equal(0, dice.MinVal); + Assert.Equal(5, dice.MaxVal); } [Fact] @@ -44,6 +44,6 @@ public class DiceTests { Dice dice = new Dice(); dice.Roll(); - Assert.True(dice.Value >= dice.NbMin && dice.Value <= dice.NbMax); + Assert.True(dice.Value >= dice.MinVal && dice.Value <= dice.MaxVal); } }