Exemplo n.º 1
0
        static void Main(string[] args)
        {
            // Test program to test all constructors and public methods
            MyPoint p1 = new MyPoint();              // Test constructor

            Console.WriteLine(p1);                   // Test toString()
            p1.SetX(8);                              // Test setters
            p1.SetY(6);
            Console.WriteLine("x is: " + p1.GetX()); // Test getters
            Console.WriteLine("y is: " + p1.GetY());
            p1.setXY(3, 0);                          // Test setXY()
            Console.WriteLine(p1.GetXY()[0]);        // Test getXY()
            Console.WriteLine(p1.GetXY()[1]);
            Console.WriteLine(p1);

            MyPoint p2 = new MyPoint(0, 4);  // Test another constructor

            Console.WriteLine(p2);
            // Testing the overloaded methods distance()
            Console.WriteLine(p1.distance(p2));    // which version?
            Console.WriteLine(p2.distance(p1));    // which version?
            Console.WriteLine(p1.distance(5, 6));  // which version?
            Console.WriteLine(p1.distance());      // which version?
        }
Exemplo n.º 2
0
 public double distance(MyPoint another)
 {
     return(distance(another.GetX(), another.GetY()));
 }