diff --git a/MCTG/MCTGApp/MCTGApp.csproj b/MCTG/MCTGApp/MCTGApp.csproj index f02677b..7517cf8 100644 --- a/MCTG/MCTGApp/MCTGApp.csproj +++ b/MCTG/MCTGApp/MCTGApp.csproj @@ -1,4 +1,4 @@ - + Exe @@ -7,4 +7,8 @@ enable + + + + diff --git a/MCTG/MCTGApp/Program.cs b/MCTG/MCTGApp/Program.cs index 3751555..c45d82d 100644 --- a/MCTG/MCTGApp/Program.cs +++ b/MCTG/MCTGApp/Program.cs @@ -1,2 +1,32 @@ -// See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); +using System; +using MCTG.Model; + + +namespace MCTG.Program; + +public static class Program +{ + public static void Main() + { + Console.WriteLine("Helle World!"); + + Recipe recipe = new Recipe( + 1, + "Cookies aux pépites de chocolat", + new List(new string[]{ + "2 pommes", + "3L de vin", + "500g de farine" + }), + "Etape 1:\n" + + "\tCouper les pommes\n" + + "Etape 2:\n" + + "\tLes disposer sur le plat et mettre le vin dessus\n" + + "Etape 3:\n" + + "\tMettez toute la farine ensuite, puis 4h32 au four.\n" + + "\nDégustez c'est prêt !" + ); + + recipe.Display(); + } +} \ No newline at end of file diff --git a/MCTG/MCTGLib/Class1.cs b/MCTG/MCTGLib/Class1.cs deleted file mode 100644 index 5b51184..0000000 --- a/MCTG/MCTGLib/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace MCTGLib -{ - public class Class1 - { - - } -} \ No newline at end of file diff --git a/MCTG/MCTGLib/Recipe.cs b/MCTG/MCTGLib/Recipe.cs new file mode 100644 index 0000000..b69d842 --- /dev/null +++ b/MCTG/MCTGLib/Recipe.cs @@ -0,0 +1,60 @@ +using System.Text; + +namespace MCTG.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()); + } + } +} \ No newline at end of file