using System.Text; namespace Model { public class Recipe { public uint Id { get; set; } public string Title { get; set; } public List Ingredients { get; set; } public string Preparation { get; set; } /// /// Constructor of a Recipe. /// /// Identificator /// The name of the recipe /// A list of ingredient needed by the preparation /// The text that explain the preparation of the recipe public Recipe(uint id, string title, List ingredients, string preparation) { Id = id; Title = title; Ingredients = ingredients; Preparation = preparation; } /// /// Concatenate the list of ingredients in a single string /// /// The list of ingredients in string format private string ConcatIngredients() { StringBuilder sb = new StringBuilder(); foreach (string str in Ingredients) sb.Append("\t- " + str + "\n"); return sb.ToString(); } /// /// Build a string with all elements (title, ingredients, preparation, ...) /// /// A string that represent the recipe public override string ToString() { return $"{Title} -- id:{Id}\n\n" + "List of ingredient:\n" + ConcatIngredients() + "\n\n" + "Preparation:\n" + $"{Preparation}\n"; } /// /// Display the recipe in the console /// public void Display() { Console.WriteLine(this.ToString()); } } }