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.
SAE-2.01/MCTG/Model/Quantity.cs

70 lines
1.8 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
/// <summary>
/// Quantity is a class which is associate to Ingedients. It represents the quantity of every ingredient with an enum
/// to indicate the unit of the quantity.
/// </summary>
[DataContract(Name ="quantity")]
public class Quantity
{
#region Attributes
/// <summary>
/// get the quatity of ingredient
/// </summary>
[DataMember(Name ="digit")]
private int number;
/// <summary>
/// have the Unit enum of the quantity of ingredient
/// </summary>
[DataMember(Name ="unit")]
private Unit unit;
#endregion
#region Properties
/// <summary>
/// Represents the quantity in digits. The null value raise an argumentException.
/// </summary>
public int Number
{
get { return number; }
set
{
if (value < 0)
{
throw new ArgumentException("Si la quantité est inférieur à 0, enlever l'ingrédient!");
}
number = value;
}
}
public Unit UnitQ
{
get => unit;
set => unit = value;
}
#endregion
#region Constructor
/// <summary>
/// Constructor of Quantity
/// </summary>
/// <param name="number"></param>
/// <param name="unit"></param>
public Quantity(int number, Unit unit)
{
Number = number;
UnitQ = unit;
}
#endregion
}
}