Skip to content

Instantly share code, notes, and snippets.

@jsanjuan2016
Last active January 27, 2021 15:37
Show Gist options
  • Save jsanjuan2016/f8105e4daaf31ab8aa0ae0ef2ad991ae to your computer and use it in GitHub Desktop.
Save jsanjuan2016/f8105e4daaf31ab8aa0ae0ef2ad991ae to your computer and use it in GitHub Desktop.
public class WindowManager
{
private readonly IShapeFactory<Rectangle> _rectangleFactory;
private readonly IShapeFactory<Cirlce> _CircleFactory;
public WindowManager(IShapeFactory<Rectangle> rectangleFactory, IShapeFactory<Cirlce> CirlceFactory)
{
this._rectangleFactory = rectangleFactory ?? throw new ArgumentNullException(nameof(rectangleFactory));
this._CircleFactory = CirlceFactory ?? throw new ArgumentNullException(nameof(CirlceFactory));
}
public void CreateRectangleWithUserParams(IShapeParameters parameters)
{
IShape rectangle = this._rectangleFactory.CreateShape(parameters);
Console.WriteLine($"Factory: Rectangle created");
Console.WriteLine($"Factory: El área del Rectangle es: {rectangle.getArea():0.00}");
}
public void CreateCircleWithUserParams(IShapeParameters parameters)
{
IShape Cirlce = this._CircleFactory.CreateShape(parameters);
Console.WriteLine($"Factory: Cirlce created");
Console.WriteLine($"Factory: El área de la ventana es: {Cirlce.getArea():0.00}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment