Exemplo n.º 1
0
 public void Should_Create_A_Point(int xToTest, int yTotest)
 {
     var point = new Point(xToTest, yTotest);
     Assert.IsNotNull(point);
     Assert.AreEqual(point.X, xToTest);
     Assert.AreEqual(point.Y, yTotest);
     Assert.IsTrue(point.ToString().Contains(xToTest.ToString()));
     Assert.IsTrue(point.ToString().Contains(yTotest.ToString()));
 }
Exemplo n.º 2
0
 public void Should_Create_A_Default_Valuated_Point()
 {
     var point = new Point();
     Assert.IsNotNull(point);
     Assert.AreEqual(point.X, 0);
     Assert.AreEqual(point.Y, 0);
     Assert.IsTrue(point.ToString().Contains("0"));
 }
Exemplo n.º 3
0
        private static string FindPath(Point from, Point to)
        {
            string path = to.ToString() + "\"]";

            while (!from.Equals(to))
            {
                List <Point> currentwave = new List <Point> {
                    from
                };

                while (!CheckTo(currentwave, to))
                {
                    List <Point> nextvawe = new List <Point>();
                    foreach (Point nextpoint in currentwave)
                    {
                        foreach (Point offset in horseSteps)
                        {
                            Point p = ShiftPoint(nextpoint, offset);

                            p.from = nextpoint.ToString();

                            /*
                             * здесь можно вставить проверку не занято ли поле с координатами р
                             *
                             */
                            nextvawe.Add(p);
                        }

                        currentwave = nextvawe;
                    }
                }
                path = "\"" + foundedFrom + "\"," + path;

                to = ParsePoint(foundedFrom);
            }

            return("[" + path);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            Point pt = new Point(5, 10);

            Console.WriteLine(pt.ToString());
        }