Ludovic Lagouardette 2 lat temu
rodzic
commit
78a7b1a6c1
7 zmienionych plików z 91 dodań i 8 usunięć
  1. +12
    -0
      Beverages/Coffee.cs
  2. +23
    -0
      Beverages/Erythriol.cs
  3. +3
    -1
      Beverages/IBeverage.cs
  4. +2
    -1
      Beverages/IPhysicalProperties.cs
  5. +1
    -1
      Beverages/ISweetener.cs
  6. +45
    -0
      Beverages/Tea.cs
  7. +5
    -5
      Exercice2/Program.cs

+ 12
- 0
Beverages/Coffee.cs Wyświetl plik

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Beverages
{
class Coffee
{
}
}

+ 23
- 0
Beverages/Erythriol.cs Wyświetl plik

@ -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";
}
}
}

+ 3
- 1
Beverages/IBeverage.cs Wyświetl plik

@ -6,7 +6,9 @@ using System.Threading.Tasks;
namespace Beverages
{
interface IBeverage
public interface IBeverage : IPhysicalProperties
{
void Sweeten(ISweetener sweetener);
List<ISweetener> GetSweetenersList();
}
}

+ 2
- 1
Beverages/IPhysicalProperties.cs Wyświetl plik

@ -6,7 +6,8 @@ using System.Threading.Tasks;
namespace Beverages
{
interface IPhysicalProperties
public interface IPhysicalProperties
{
float GetTemperature();
}
}

+ 1
- 1
Beverages/ISweetener.cs Wyświetl plik

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Beverages
{
interface ISweetener
public interface ISweetener
{
}
}

+ 45
- 0
Beverages/Tea.cs Wyświetl plik

@ -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<ISweetener> sweeteners;
public Tea(TeaType type)
{
this.type = type;
sweeteners = new List<ISweetener>();
}
public List<ISweetener> GetSweetenersList()
{
return sweeteners;
}
public void Sweeten(ISweetener sweetener)
{
sweeteners.Add(sweetener);
}
public float GetTemperature()
{
if (type == TeaType.Iced)
{
return 5;
}
return 98;
}
}
}

+ 5
- 5
Exercice2/Program.cs Wyświetl plik

@ -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");
p">/*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");*/
}
}
}

Ładowanie…
Anuluj
Zapisz