private static void Main(string[] args) { //create list of shapes var shapes = new List <Shape> { new Circle() { Height = 100, Width = 100 }, new Rectangle() { Height = 20, Width = 80 }, new Triangle() { Height = 50, Width = 100 }, new Square() { Height = 50, Width = 50 } }; //create canvas object and draw the shapes var canvas = new Canvas(); canvas.DrawShapes(shapes); }
static void Main(string[] args) { var shapes = new List<Shape>(); shapes.Add(new Circle()); shapes.Add(new Rectangle()); var canvas = new Canvas(); canvas.DrawShapes(shapes); }
static void Main(string[] args) { var shape = new List <Shape>(); shape.Add(new Circule()); shape.Add(new Rectangule()); var canvas = new Canvas(); canvas.DrawShapes(shape); Console.WriteLine("*************"); shape.Add(new Triangule()); canvas.DrawShapes(shape); }
static void Main(string[] args) { var shapes = new List<Shape>(); shapes.Add(new Circle { Width = 100, Height = 100, Position = new Position { X = 50, Y = 50 } }); shapes.Add(new Rectangle { Width = 100, Height = 50, Position = new Position { X = 100, Y = 100 } }); var canvas = new Canvas(); canvas.DrawShapes(shapes); }
static void Main(string[] args) { var shapes = new List <Shape>(); shapes.Add(new Circle()); shapes.Add(new Rectangle()); var canvas = new Canvas(); canvas.DrawShapes(shapes); }
static void Main(string[] args) { //We can not create or instanciate an object from a class that is abstract. var shapes = new List <Shape>(); shapes.Add(new Circle()); shapes.Add(new Rectangle()); shapes.Add(new Triangle()); var canvas = new Canvas(); canvas.DrawShapes(shapes); }
static void Main(string[] args) { var shapes = new List<Shape>(); //shapes.Add(new Shape { Width = 100, Height = 100, Type = ShapeType.Square}); //shapes.Add(new Shape { Width = 100, Height = 30, Type = ShapeType.Hexagon}); shapes.Add(new Circle()); shapes.Add(new Hexagon()); var canvas = new Canvas(); canvas.DrawShapes(shapes); }
static void Main(string[] args) { var shapes = new List <Shape>(); //shapes.Add(new Shape { Width = 100, Height = 100, Type = ShapeType.Circle }); //shapes.Add(new Shape { Width = 100, Height = 30, Type = ShapeType.Rectangle }); shapes.Add(new Circle()); shapes.Add(new Rectange()); var canvas = new Canvas(); canvas.DrawShapes(shapes); }
public static void Main(string[] args) { var shapes = new List <Shape>(); shapes.Add(new Circle()); shapes.Add(new Rectangle()); //the following was the original with switch case, now got replaced with polymorphism //shapes.Add(new Shape { Width = 100, Height = 100, Type = ShapeType.Circle }); //shapes.Add(new Shape { Width = 100, Height = 30, Type = ShapeType.Rectangle }); var canvas = new Canvas(); canvas.DrawShapes(shapes); }
static void Main(string[] args) { var shapes = new List <Shape>(); //shapes.Add(new Shape { Width = 100, Height = 100 }); //shapes.Add(new Shape { Width = 100, Height = 30 }); shapes.Add(new Circle()); shapes.Add(new Rectangle()); shapes.Add(new Triangle()); var canvas = new Canvas(); canvas.DrawShapes(shapes); Console.ReadLine(); }
static void Main(string[] args) { var shapes = new List <Shape>(); shapes.Add(new Circle { Width = 100, Height = 100 }); shapes.Add(new Rectangle() { Width = 100, Height = 30 }); var canvas = new Canvas(); canvas.DrawShapes(shapes); }
static void Main(string[] args) { var circle1 = new Circle(); var rectangle = new Rectangle(); var circle2 = new Circle(); var listOfShapes = new List <Shape>(); listOfShapes.Add(circle1); listOfShapes.Add(rectangle); listOfShapes.Add(circle2); listOfShapes.Add(new Triangle()); var canvas = new Canvas(); canvas.DrawShapes(listOfShapes); Console.ReadKey(); }