static void Main(string[] args)
        {
            // Modern things

            IFurnitureFactory furnitureFactory = new ModernFurnitureFactory();

            IChair chair = furnitureFactory.CreateChair();
            ITable table = furnitureFactory.CreateCoffeeTable();

            chair.HasLegs();
            chair.SitOn();

            table.Shape();
            table.SitNextTo();

            // Viktorian things

            furnitureFactory = new ViktorianFurnitureFactory();

            chair = furnitureFactory.CreateChair();
            table = furnitureFactory.CreateCoffeeTable();

            chair.HasLegs();
            chair.SitOn();

            table.Shape();
            table.SitNextTo();
        }
        /// <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();
        }
Exemplo n.º 3
0
 private void ShowChairInfo(IChair chair)
 {
     Console.WriteLine($"{chair.GetType().Name} has legs: {chair.HasLegs()}");
     chair.SitOn();
 }
Exemplo n.º 4
0
 public void Eat()
 {
     _chair.SitOn();
     _table.GetFoodFrom();
 }
Exemplo n.º 5
0
        public string AnotherUsefulFunctionCoffeeTable(IChair collaboratorChair)
        {
            var result = collaboratorChair.SitOn();

            return($"The result of Modern coffee Table collaborating with {result}");
        }