Create a class Point, which defines a point on the coordinate plane. Implement a count of the number of created instances of type Point
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Q178961
{
    class Program
    {
        class Point {
            private int x;
            private int y;
            public static int counter=0;
            public Point() {
                counter++;
            }
            public Point(int x,int y)
            {
                this.x = x;
                this.y = y;
                counter++;
            }
            public int X
            {
                get { return x; }
                set { x = value; }
            }
            
            public int Y
            {
                get { return y; }
                set { y = value; }
            }
        }
        static void Main(string[] args)
        {
            Point Point1 = new Point();
            Console.WriteLine("The number of created instances of type Point: {0}", Point.counter);
            Point Point2 = new Point(5,6);
            Console.WriteLine("The number of created instances of type Point: {0}", Point.counter);
            Console.ReadLine();
        }
    }
}
Comments