using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Model { /// /// Define a step of the preparation of a recipe. /// public class PreparationStep : IEquatable { #region Attributes private string? _description; #endregion #region Properties /// /// The order of this step in the preparation of the meal. /// public int Order { get; init; } /// /// The description of the task the user need to do for this step of the preparation.
/// Set to "No description." when the value passed is null, empty or contain white spaces. ///
public string? Description { get => _description; set { if (string.IsNullOrWhiteSpace(value)) _description = "No description."; else _description = value; } } #endregion #region Constructors /// /// Construct a new step of preparation. /// /// The number of the order in preparation /// The description of the task public PreparationStep(int order, string? description) { Order = order; Description = description; } #endregion #region Methods public bool Equals(PreparationStep? other) { return Order.Equals(other.Order) && Description.Equals(other.Description); } public override string ToString() { return $"{Order}- {Description}"; } #endregion } }