Exemple #1
0
        static void doWork()
        {
            Console.WriteLine("Running class program...");
            //int nicki = 42;
            //int = integer which is a type, nicki is a name, = is an assignment operator
            Point origin = new Point();
            //it instantiates a point object name origin
            //Point() is a constructor which returns a memory address
            //new allocates memory and returns a memory address
            //origin is a name, and Point is a type
            Point bottomRight = new Point(1366, 768);
            //constructor point has integers of 1366, 786 allocated memory by new assigned to the name bottomright
            //it instantiates a point object name bottomright
            Point  proof    = new Point();
            double distance = origin.DistanceTo(bottomRight);

            Console.WriteLine($"Distance is: {distance}");
            Point Nicki  = new Point(0, 0);
            Point Dwaine = new Point(3, 4);

            distance = Nicki.DistanceTo(Dwaine);
            Console.WriteLine($"Distance between nicki and dwaine is: {distance}");
            Point Matt = new Point(6, 25);

            Console.WriteLine($"Number of Point objects: {Point.ObjectCount()}");
        }
Exemple #2
0
 static void doWork()
 {
     Point origin = new Point();
     Point bottomRight = new Point(1366, 768);
     double distance = origin.DistanceTo(bottomRight);
     Console.WriteLine("Distance is: {0}", distance);
     Console.WriteLine("Number of Point objects: {0}", Point.ObjectCount());
 }
Exemple #3
0
 public static void Entrance()
 {
     Point point1 = new Point();
     Point point2 = new Point(1024, 1200);
     double distance = point1.DistanceTo(point2);
     Console.WriteLine("Distance is {0}", distance);
     Console.WriteLine("Number of Point objects: {0}", Point.ObjectCount());
 }
Exemple #4
0
 static void DoWork()
 {
     Point origin = new Point();
     Point bottomRight = new Point(1024, 1280);
     double distance = origin.DistanceTo(bottomRight);
     Console.WriteLine("Distance is: {0}", distance);
     Console.WriteLine("No of Point objects: {0}", Point.ObjectCount());
 }
Exemple #5
0
        static void doWork()
        {
            Point  origin      = new Point();
            Point  bottomRight = new Point(1366, 768);
            double distance    = origin.DistanceTo(bottomRight);

            Console.WriteLine($"Distance is: {distance}");
        }
Exemple #6
0
        static void doWork()
        {
            Point  origin      = new Point(); //IT goes to the heap it allocates space sufficient for the objeect and returns the address
            Point  bottomRight = new Point(1366, 768);
            double distance    = origin.DistanceTo(bottomRight);

            Console.WriteLine($"Distance is: {distance}");
            Console.WriteLine($"Number of Point objects: {Point.ObjectCount()}");
        }
Exemple #7
0
        static void DoWork()
        {
            Point  origin      = new Point();
            Point  bottomRight = new Point(1024, 1280);
            double distance    = origin.DistanceTo(bottomRight);

            Console.WriteLine("Distance is: {0}", distance);
            Console.WriteLine("No of Point objects: {0}", Point.ObjectCount());
        }
Exemple #8
0
        static void doWork()
        {
            Point  origin      = new Point();
            Point  bottomRight = new Point(1366, 768);
            double distance    = origin.DistanceTo(bottomRight);

            Console.WriteLine($"distance is: {distance}");
            Console.WriteLine($"Number of Point objects: {Point.ObjectCount()}");
        }
Exemple #9
0
        static void DoWork()
        {
            var origin      = new Point();
            var bottomRight = new Point(1366, 768);
            var distance    = origin.DistanceTo(bottomRight);

            Console.WriteLine("Distance is: {0}", distance);
            Console.WriteLine("Number of Point objects: {0}", Point.ObjectCount());
        }
Exemple #10
0
        static void doWork()
        {
            Console.WriteLine("Running Class program...");
            Point  origin      = new Point();          //intantiates point object origin
            Point  bottomRight = new Point(1366, 768); //instantiate point object bottom right
            double distance    = origin.DistanceTo(bottomRight);

            Console.WriteLine($"Distance is: {distance}");
            Console.WriteLine($"Number of Point objects: {Point.ObjectCount()}");
        }
Exemple #11
0
        static void doWork()
        {
            Point  origin      = new Point(); //creates new instance of point; invokes its default constructor
            Point  bottomRight = new Point(1366, 768);
            double distance    = origin.DistanceTo(bottomRight);

            Console.WriteLine($"Distance is: {distance}");
            (int xVal, int yVal) = origin; // deconstruct to retrieve private fields
            Console.WriteLine($"Deconstructor values. x = {xVal}, y = {yVal}");
            Console.WriteLine($"Number of Point objects: {Point.ObjectCount()}");
        }
Exemple #12
0
        static void doWork()
        {
            Point  origin      = new Point();
            Point  bottomRight = new Point(1366, 768);
            Point  Ajay        = new Point(77, 12);
            double distance    = origin.DistanceTo(bottomRight);
            double distance2   = Ajay.DistanceTo(origin);
            int    oc          = Point.ObjectCount();

            Console.WriteLine($"the object count is {oc}");
        }
Exemple #13
0
        static void doWork()
        {
            Point origin      = new Point(3, 4);                // This is the constructor
            Point origin2     = new Point();
            Point origin3     = new Point(3, 5, 7);
            Point bottomRight = new Point(1366, 768);
            Point point1      = new Point(0, 0);
            Point point2      = new Point(3, 4);
            Point origin4     = new Point(1, 2, 3);

            Console.WriteLine($"distance between point1 and point2 is: " +
                              $"{point1.DistanceTo(point2)}");
            Console.WriteLine($"distance between point2 and point1 is: " +
                              $"{point2.DistanceTo(point1)}");              // Instance method DistanceTo is called on the instance Point
            Console.WriteLine($"distance between point1 and point1 is: " +
                              $"{point1.DistanceTo(point1)}");
            Console.WriteLine($"The number of points created is: " +
                              $"{Point.ObjectCount()}");
            Console.WriteLine($"distance between origin3 and origin4 is: " +
                              $"{origin3.DistanceToTriple(origin4)}");
        }
Exemple #14
0
        static void doWork()
        {
            Point ori = new Point();

            (int x, int y) = ori;



            Point  xM       = new Point(1366, 768);
            double distance = xM.DistanceTo(ori);

            Console.WriteLine($"Distance is:{distance}");
        }
Exemple #15
0
        static void doWork()
        {
            Point  origin      = new Point();
            Point  bottomRight = new Point(1366, 768);
            double distance    = origin.DistanceTo(bottomRight);

            Console.WriteLine($"Distance is: {distance}");
            Point maxwell = new Point(1, 1);
            Point christy = new Point(4, 5);

            distance = maxwell.DistanceTo(christy);
            Console.WriteLine($"Distance is: {distance}");
            Console.WriteLine($"Number of Point objects: {Point.ObjectCount()}." +
                              $" This is the value of objectCount.");
        }
Exemple #16
0
        static void doWork()
        {
            Point  origin      = new Point();          // instances of the class
            Point  bottomRight = new Point(1366, 768); // instances// point object
            double distance    = origin.DistanceTo(bottomRight);

            Console.WriteLine($"Distance is: {distance}");
            Point maxwell = new Point(1, 1);
            Point roxana  = new Point(4, 5);

            distance = maxwell.DistanceTo(roxana);
            Console.WriteLine($"Distance is: {distance}");
            Console.WriteLine($"Number of Point objects:{Point.ObjectCount()}." +
                              $"This is he value of objectCount");
        }
        private static void DoWork()
        {
            Point origin      = new Point();
            Point bottomRight = new Point(1366, 768);

            double distance = origin.DistanceTo(bottomRight);

            Console.WriteLine($"Distance is {distance}");

            (int xVal, int yVal) = bottomRight;

            Console.WriteLine($"bottomRight._x = {xVal}, bottomRight._y = {yVal}");

            Console.WriteLine($"Number of Point objects: {Point.ObjectCount()}");
        }
Exemple #18
0
        static void doWork()
        {
            Point origin      = new Point();     //orgin is an object or an instance
            Point origin1     = new Point(2, 3); //orgin1 is an object or an instance
            Point bottomRight = new Point(1366, 768);
            Point first       = new Point(0, 0);
            Point second      = new Point(4, 3);

            double distance = first.DistanceTo(second);

            Console.WriteLine($"Distance 2 is {distance}");
            double distance2 = origin.DistanceTo(bottomRight);

            Console.WriteLine($"Distance is: {distance2}");
            Console.WriteLine($"Number of Point objects: {Point.ObjectCount()}");
        }
Exemple #19
0
        static void doWork()
        {
            Point  origin      = new Point();                    // default constructor
            Point  bottomRight = new Point(1366, 768);           // a setted point
            Point  NewP        = new Point();                    // new random point
            double distance    = origin.DistanceTo(bottomRight); //Distance from point 1(origin) to point 2(bottomRight)

            Console.WriteLine("Distance is: {0}", distance);     //Print the distance for the 2 setted points
            //Print the number of point objects
            Console.WriteLine("Number of Point objects: {0}", Point.ObjectCount());
            //-----------------//
            double distance2 = bottomRight.DistanceTo(NewP);  //print the distance from Point2(bottomRight) to Point 3(NewP)

            Console.WriteLine("Distance is: {0}", distance2); //Print the distance
            //-----------------//
        }
        static void doWork()
        {
            Point origin      = new Point();                  // creates an object named origin
            Point bottomright = new Point(1366, 768);         // calls the overloaded constructor that accepts two arguments
                                                              // and creates another object named bottomright

            double distance = origin.DistanceTo(bottomright); // creates a local variable named distance. distance is assigned the value of the calculation

            // done by specifying the object and accessing the public method named distanceto within that
            // class's definition that accepts classes as an argument and passes in the object
            // named bottomright as argument. origin is the default constructor so x,y are -1,-1 and the
            // method distanceto accepts the values input to the overloaded constructor as one object and
            // executes its body of code using these arguments.
            Console.WriteLine($"Distance is : {distance}");
            Console.WriteLine($"object count is {Point.Objectcount()}");
        }
Exemple #21
0
        static void doWork()
        {
            Console.WriteLine("Running class program");
            Point  origin      = new Point();
            Point  bottom      = new Point();
            Point  proof       = new Point();
            Point  bottomRight = new Point(1366, 768);
            double distance    = origin.DistanceTo(bottomRight);

            Console.WriteLine($"Distance is: {distance}");
            Point jennifer = new Point(0, 0);
            Point johnny   = new Point(3, 4);

            distance = jennifer.DistanceTo(johnny);
            Console.WriteLine($"Distance between Jennifer and Johnny is: {distance}");
            Point peter = new Point(63, 180);

            Console.WriteLine($"Number of Point objects: {Point.ObjectCount()}");
        }
Exemple #22
0
        /// <summary>
        /// Start method for our program
        /// </summary>
        /// <param name="args">array of program parameters from console</param>
        static void Main(string[] args)
        {
            //Skapa Circle objekt
            Circle c1 = new Circle(1);
            //Kopiera objektreferencen
            Circle c2 = c1;
            //Gör en kopia
            Circle c3 = c1.Clone();

            //Gör en kopiering av data
            Circle c4 = new Circle();

            //c1.CopyTo(c4);

            //Skriv ut alla objektens radier
            Console.WriteLine("C1: " + c1.Radius);
            Console.WriteLine("C2: " + c2.Radius);
            Console.WriteLine("C3: " + c3.Radius);
            Console.WriteLine("C4: " + c4.Radius);
            Console.ReadLine();

            //Öka värdet på c1's radie
            c1.Radius++;
            //Skriv ut alla objektens radier
            Console.WriteLine("C1: " + c1.Radius);
            Console.WriteLine("C2: " + c2.Radius);
            Console.WriteLine("C3: " + c3.Radius);
            Console.WriteLine("C4: " + c4.Radius);
            Console.ReadLine();

            //Test av Point klassen och dess DistanceTo metod

            Point point1 = new Point(3, 4);
            Point point2 = new Point(6, 8);

            Point point3 = new Point(point1);

            double distance = point3.DistanceTo(point2);

            Console.WriteLine("Distance: " + distance);
            Console.ReadLine();
        }
Exemple #23
0
        /// <summary>
        /// Start method for our program
        /// </summary>
        /// <param name="args">array of program parameters from console</param>
        static void Main(string[] args)
        {
            //Skapa Circle objekt
            Circle c1 = new Circle(1);
            //Kopiera objektreferencen
            Circle c2 = c1;
            //Gör en kopia
            Circle c3 = c1.Clone();

            //Gör en kopiering av data
            Circle c4 = new Circle();
            //c1.CopyTo(c4);

            //Skriv ut alla objektens radier
            Console.WriteLine("C1: " +  c1.Radius);
            Console.WriteLine("C2: " + c2.Radius);
            Console.WriteLine("C3: " + c3.Radius);
            Console.WriteLine("C4: " + c4.Radius);
            Console.ReadLine();

            //Öka värdet på c1's radie
            c1.Radius++;
            //Skriv ut alla objektens radier
            Console.WriteLine("C1: " + c1.Radius);
            Console.WriteLine("C2: " + c2.Radius);
            Console.WriteLine("C3: " + c3.Radius);
            Console.WriteLine("C4: " + c4.Radius);
            Console.ReadLine();

            //Test av Point klassen och dess DistanceTo metod

            Point point1 = new Point(3, 4);
            Point point2 = new Point(6, 8);

            Point point3 = new Point(point1);

            double distance = point3.DistanceTo(point2);
            Console.WriteLine("Distance: " + distance);
            Console.ReadLine();
        }
Exemple #24
0
        static void doWork()
        {
            Point origin      = new Point();
            Point origin1     = new Point(2, 3);
            Point bottomRight = new Point(1366, 768);
            Point first       = new Point(0, 0);
            Point second      = new Point(4, 3);

            first.ToString();
            second.ToString();

            double distance2 = first.DistanceTo(second);

            Console.WriteLine($"Distance2 is {distance2}");
            double distance = origin.DistanceTo(bottomRight);

            Console.WriteLine($"Distance is: {distance}");
            Console.WriteLine($"Number of Point objects: {Point.ObjectCount()}");
            double distance3 = second.DistanceTo(first);

            Console.WriteLine($"Distance3 is {distance3}");
        }