public static string[] Run(IFurnitureFactory factory) { var chair1 = factory.CreateChair(); var chair2 = factory.CreateChair(); var table = factory.CreateTable(); return(new[] { $"Price for chair1: {chair1.Price}", $"Price for chair2: {chair2.Price}", $"Price for table: {table.Price}", $"Number of chairs to get discount: {table.NrOfChairsToGetDiscount}", $"Price for table with chair1 and chair2: {(int)table.PriceWithChairs(chair1,chair2)}" }); }
/// <summary> /// Simulates the client code only knowing it gets a Factory. /// Probably some service/handler that gets injected with the IFurnitureFactory /// but does not know what implementation types /// </summary> private static void DescribeChair(IFurnitureFactory factory) { IChair chair = factory.CreateChair(); chair.SitOn(); chair.HasLegs(); }
public void ClientMethod(IFurnitureFactory furnitureFactory) { var productA = furnitureFactory.CreateChair(); var productB = furnitureFactory.CreateSofa(); System.Console.WriteLine(productA.UseFullFunction()); }
public void ClientMethod(IFurnitureFactory factory) { var chair = factory.CreateChair(); var sofa = factory.CreateSofa(); Console.WriteLine(sofa.Type()); Console.WriteLine(sofa.Print(chair)); }
static void CreateFurniture(IFurnitureFactory factory) { factory.CreateChair().ShowInfo(); factory.CreateSofa().ShowInfo(); factory.CreateTable().ShowInfo(); Console.WriteLine(); }
private static void CreateFurniture(IFurnitureFactory factory) { var chair = factory.CreateChair(); var sofa = factory.CreateSofa(); var table = factory.CreateTable(); chair.PrintInfo(); sofa.PrintInfo(); table.PrintInfo(); }
static void RunApplication(IFurnitureFactory factory) { var chair = factory.CreateChair(); var sofa = factory.CreateSofa(); WriteLine($"This chair has{(chair.HasLegs() ? "": " not")} legs"); WriteLine($"This sofa has{(sofa.HasLegs() ? "" : " not")} legs"); chair.SeatOn(); sofa.SeatOn(); ReadLine(); }
public static void ClientMethod(IFurnitureFactory factory) { Console.WriteLine($"---------------Order in {factory}---------------"); var chair = factory.CreateChair(); chair.hasLegs(); chair.sitOn(); var sofa = factory.CreateSofa(); sofa.hasBack(); sofa.hasLegs(); sofa.lieOn(); sofa.sitOn(); }
private void ClientMethod(IFurnitureFactory factory) { var chair = factory.CreateChair(); _testOutputHelper.WriteLine(chair.SittingOnChair()); var sofa = factory.CreateSofa(); _testOutputHelper.WriteLine(sofa.SittingOnSofa()); var coffeeTable = factory.CreateCoffeeTable(); _testOutputHelper.WriteLine(coffeeTable.UseTable()); }
private static void PrintSelectedCollectionDetails(IFurnitureFactory furnitureFactory, string selectedCollection) { var chair = furnitureFactory.CreateChair(); var coffeeTable = furnitureFactory.CreateCoffeeTable(); var sofa = furnitureFactory.CreateSofa(); Console.WriteLine($"***** collection name: {selectedCollection} *****"); Console.WriteLine($"Chair{Environment.NewLine}" + $"Design: {chair.Design} {Environment.NewLine}" + $"Construction: {chair.Construction} {Environment.NewLine}"); Console.WriteLine($"Coffee Table{Environment.NewLine}" + $"Design: {coffeeTable.Design} {Environment.NewLine}" + $"Construction: {coffeeTable.Construction} {Environment.NewLine}"); Console.WriteLine($"Sofa{Environment.NewLine}" + $"Design: {sofa.Design} {Environment.NewLine}" + $"Construction: {sofa.Construction} {Environment.NewLine}"); }
public Factory(IFurnitureFactory factory) { _bed = factory.CreateBed(); _chair = factory.CreateChair(); }
public Client(IFurnitureFactory factory) { Chair = factory.CreateChair(); Table = factory.CreateTable(); }