Exemplo n.º 1
0
 public myParallelogram(MyPoint a, MyPoint b, MyPoint c, MyPoint d)
 {
     A = a;
     B = b;
     C = c;
     D = d;
 }
Exemplo n.º 2
0
 public bool is_between(MyPoint one, MyPoint two)
 {
     double exp1 = getDistance(one) + getDistance(two);
     double exp2 = one.getDistance(two);
     double exp3 = exp1 - exp2;
     if (exp3 < 0)
         exp3 *= -1;
     return exp3 < coefficient_error;
 }
Exemplo n.º 3
0
        public void TestMethod1()
        {
            MyPoint a = new MyPoint(0, 0);
            MyPoint b = new MyPoint(0, 3);
            MyPoint c = new MyPoint(4, 3);
            MyPoint d = new MyPoint(4, 0);

            MyPoint e = new MyPoint(2, 2);

            myParallelogram parall = new myParallelogram(a, b, c, d);

            Assert.AreEqual(true, parall.isCorrect(), "correct data chelking");
            parall = new myParallelogram(a, b, e, d);
            Assert.AreEqual(false, parall.isCorrect(), "incorrect data chelking");
        }
Exemplo n.º 4
0
 public double Distance(MyPoint point)
 {
     return(Distance(point.GetX(), point.GetY()));
 }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            //Author a1 = new Author("ThanhNhan", "*****@*****.**", 'A');
            //Console.WriteLine(a1);
            //a1.setEmail("*****@*****.**");
            //Console.WriteLine("name is: " + a1.getName());
            //Console.WriteLine("eamil is: " + a1.getEmail());
            //Console.WriteLine("gender is: " + a1.getGender());

            //------------------------------Book--------------------------------
            //Author ahTeck = new Author("Tan Ah Teck", "*****@*****.**", 'm');
            //Console.WriteLine(ahTeck);  // Author's toString()

            //Book dummyBook = new Book("Java for dummy", ahTeck, 19.95, 99);  // Test Book's Constructor
            //Console.WriteLine(dummyBook);  // Test Book's toString()

            //// Test Getters and Setters
            //dummyBook.setPrice(29.95);
            //dummyBook.setQty(28);
            //Console.WriteLine("name is: " + dummyBook.getName());
            //Console.WriteLine("price is: " + dummyBook.getPrice());
            //Console.WriteLine("qty is: " + dummyBook.getqty());
            //Console.WriteLine("Author is: " + dummyBook.getAuthors());  // Author's toString()
            //Console.WriteLine("Author's name is: " + dummyBook.getAuthors().getName());
            //Console.WriteLine("Author's email is: " + dummyBook.getAuthors().getEmail());

            //// Use an anonymous instance of Author to construct a Book instance
            //Book anotherBook = new Book("more Java",
            //      new Author("Paul Tan", "*****@*****.**", 'm'), 29.95);
            //    Console.WriteLine(anotherBook);  // toString()
            //------------------------------------------------------
            //Author[] authors = new Author[2];
            //authors[0] = new Author("Tan Ah Teck", "*****@*****.**", 'm');
            //authors[1] = new Author("Paul Tan", "*****@*****.**", 'm');

            //// Declare and allocate a Book instance
            //Book javaDummy = new Book("Java for Dummy", authors, 19.99, 99);
            //Console.WriteLine(javaDummy);  // toString()
            //-------------------------------------

            // 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.º 6
0
 public double Distance(MyPoint Point)
 {
     return(Distance(Point.x, Point.y));
 }
Exemplo n.º 7
0
 public double getDistance(MyPoint o)
 {
     return Math.Pow((Math.Pow(X - o.X, 2) + Math.Pow(Y - o.Y, 2)), 0.5);
 }