diff --git a/Beverages/Coffee.cs b/Beverages/Coffee.cs new file mode 100644 index 0000000..5f928ef --- /dev/null +++ b/Beverages/Coffee.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Beverages +{ + class Coffee + { + } +} diff --git a/Beverages/Erythriol.cs b/Beverages/Erythriol.cs new file mode 100644 index 0000000..9d1cbfd --- /dev/null +++ b/Beverages/Erythriol.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Beverages +{ + public class Erythriol : ISweetener + { + double quantityGrams; + + public Erythriol(double quantityGrams) + { + this.quantityGrams = quantityGrams; + } + + public override string ToString() + { + return "Erythriol " + quantityGrams + "g"; + } + } +} diff --git a/Beverages/IBeverage.cs b/Beverages/IBeverage.cs index 7b248d1..5f08b4a 100644 --- a/Beverages/IBeverage.cs +++ b/Beverages/IBeverage.cs @@ -6,7 +6,9 @@ using System.Threading.Tasks; namespace Beverages { - interface IBeverage + public interface IBeverage : IPhysicalProperties { + void Sweeten(ISweetener sweetener); + List GetSweetenersList(); } } diff --git a/Beverages/IPhysicalProperties.cs b/Beverages/IPhysicalProperties.cs index 3438756..b87bcf6 100644 --- a/Beverages/IPhysicalProperties.cs +++ b/Beverages/IPhysicalProperties.cs @@ -6,7 +6,8 @@ using System.Threading.Tasks; namespace Beverages { - interface IPhysicalProperties + public interface IPhysicalProperties { + float GetTemperature(); } } diff --git a/Beverages/ISweetener.cs b/Beverages/ISweetener.cs index 6512511..d36ad2a 100644 --- a/Beverages/ISweetener.cs +++ b/Beverages/ISweetener.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Beverages { - interface ISweetener + public interface ISweetener { } } diff --git a/Beverages/Tea.cs b/Beverages/Tea.cs new file mode 100644 index 0000000..07b9c72 --- /dev/null +++ b/Beverages/Tea.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Beverages +{ + public enum TeaType + { + Oolong, + Iced + } + + public class Tea : IBeverage + { + TeaType type; + List sweeteners; + + public Tea(TeaType type) + { + this.type = type; + sweeteners = new List(); + } + + public List GetSweetenersList() + { + return sweeteners; + } + + public void Sweeten(ISweetener sweetener) + { + sweeteners.Add(sweetener); + } + + public float GetTemperature() + { + if (type == TeaType.Iced) + { + return 5; + } + return 98; + } + } +} diff --git a/Exercice2/Program.cs b/Exercice2/Program.cs index 249d39b..ed1404e 100644 --- a/Exercice2/Program.cs +++ b/Exercice2/Program.cs @@ -13,10 +13,10 @@ namespace Exercice2 ISweetener sugar = new Erythriol(0.5); tea.Sweeten(sugar); - Debug.Assert(tea.GetSweetenersList().Count == 1, "We put a single sweetener type"); - - IBeverage coffee = new Coffee(CoffeeType.ColdBrew); - Debug.Assert(coffee.GetTemperature() < (float)5, "Coldbrew coffee temperature needs be below 5C"); + Debug.Assert(tea.GetSweetenersList().Count == 2, "We put a single sweetener type"); + + /*IBeverage coffee = new Coffee(CoffeeType.ColdBrew); + Debug.Assert(coffee.GetTemperature() <= (float)5, "Coldbrew coffee temperature needs be below 5C"); IBeverage horror = new Mix(tea, coffee); Debug.Assert(horror.GetTemperature() < (float)55, "Horror temperature needs be average of tea and coffee"); @@ -24,7 +24,7 @@ namespace Exercice2 ISweetener coffeeSugar = new Erythriol(0.5); coffee.Sweeten(coffeeSugar); - Debug.Assert(horror.GetSweetenersList().Count == 1, "We put a single sweetener type, just more of it"); + Debug.Assert(horror.GetSweetenersList().Count == 1, "We put a single sweetener type, just more of it");*/ } } }