using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
///
/// 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.
///
[DataContract(Name = "quantity")]
public class Quantity
{
#region Attributes
///
/// get the quatity of ingredient
///
[DataMember(Name = "digit")]
private int number;
///
/// have the Unit enum of the _quantity of ingredient
///
[DataMember(Name = "unit")]
private Unit unit;
#endregion
#region Properties
///
/// Represents the _quantity in digits. The null value raise an argumentException.
///
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
///
/// Constructor of Quantity
///
///
///
public Quantity(int number, Unit unit)
{
Number = number;
UnitQ = unit;
}
#endregion
public override string ToString()
{
return $"{Number}{UnitQ}";
}
}
}