예제 #1
0
파일: Program.cs 프로젝트: yunamarth/Demo05
        static void Main(string[] args)
        {
            //  DrawingObject do = new DrawingObject();

            Circle circle = new Circle();
            circle.Name = "My Circle";
            circle.Draw();

            Square square = new Square();
            square.Name = "My Square";
            square.Draw();

            // create a List collection for Drawing Objects
            List<DrawingObject> drawingObjects = new List<DrawingObject>();
            // add a few objects to collection
            drawingObjects.Add(new Circle());
            drawingObjects.Add(new Square());
            drawingObjects.Add(new Circle());
            drawingObjects.Add(new Square());
            drawingObjects.Add(new Circle());
            drawingObjects.Add(new Square());
            drawingObjects.Add(new Circle());
            drawingObjects.Add(new Square());

            // loop collection and draw objects
            Console.WriteLine("Drawing Listed objects: ");
            foreach(DrawingObject drawingObject in drawingObjects)
            {
                drawingObject.Draw();
            }


            Console.WriteLine("Press enter key to continue");
            Console.ReadLine();
        }
예제 #2
-1
파일: Program.cs 프로젝트: HautaN7/Demo05
        static void Main(string[] args)
        {
            //DrawingObject do = new DrawingObject();

            Circle circle = new Circle();
            circle.Name = "My circle";
            circle.Draw();

            Square square = new Square();
            square.Name = "My square";
            square.Draw();

            List<DrawingObject> drawingObjects = new List<DrawingObject>();
            // add new objects t ocollection
            drawingObjects.Add(new Circle());
            drawingObjects.Add(new Square());
            drawingObjects.Add(new Circle());
            drawingObjects.Add(new Square());
            drawingObjects.Add(new Circle());
            drawingObjects.Add(new Square());

            // loop collection and draw
            Console.WriteLine("Drawing objects in a list.");
            foreach(DrawingObject drawingObject in drawingObjects)
            {
                drawingObject.Draw();
            }

            Console.WriteLine("Press enter to continue...");
            Console.ReadLine();
        }