public void PointsDistanceTaxicab()
 {
     Point p1 = new Point(10.0, 15.0);
     Point p2 = new Point(7.0, 19.0);
     IDistanceMetric metric = new TaxicabDistance();
     PointsDistance distance = new PointsDistance(metric);
     Assert.AreEqual(7.0, distance.CalculateDistance(p1, p2));
 }
Beispiel #2
0
 public void PointsDistanceTaxicab()
 {
     Point p1 = new Point(10.0, 15.0);
     Point p2 = new Point(7.0, 19.0);
     IDistanceMetric metric = new TaxicabDistance();
     PointsDistance distance = new PointsDistance(metric);
     Assert.AreEqual(7.0, distance.CalculateDistance(p1, p2));
 }
 public void PointsDistanceEuclidean()
 {
     Point p1 = new Point(10.0, 15.0);
     Point p2 = new Point(7.0, 19.0);
     IDistanceMetric metric = new EuclideanDistance();
     PointsDistance distance = new PointsDistance(metric);
     Assert.AreEqual(5.0, distance.CalculateDistance(p1, p2));
 }
Beispiel #4
0
 public void PointsDistanceEuclidean()
 {
     Point p1 = new Point(10.0, 15.0);
     Point p2 = new Point(7.0, 19.0);
     IDistanceMetric metric = new EuclideanDistance();
     PointsDistance distance = new PointsDistance(metric);
     Assert.AreEqual(5.0, distance.CalculateDistance(p1, p2));
 }
Beispiel #5
0
 public void Initialize()
 {
     // Composition root (for unit tests)
     // Compose objects here using Dependency Injection
     IDistanceMetric metric = new EuclideanDistance();
     PointsDistance distance = new PointsDistance(metric);
     this.cut = new ShootingRange(distance);
 }
Beispiel #6
0
 public ShootingRange(PointsDistance distance)
 {
     if (distance == null)
     {
         throw new ArgumentNullException(nameof(distance));
     }
     Distance = distance;
 }
Beispiel #7
0
        public void Initialize()
        {
            // Composition root (for unit tests)
            // Compose objects here using Dependency Injection
            IDistanceMetric metric   = new EuclideanDistance();
            PointsDistance  distance = new PointsDistance(metric);

            this.cut = new ShootingRange(distance);
        }
Beispiel #8
0
        static void Main()
        {
            Console.WriteLine("Biathlon");

            Point  target = ReadInitialPoint();
            double radius = 3.0;

            // Composition root (for normal program run)
            // Compose objects here using Dependency Injection
            IDistanceMetric metric   = new EuclideanDistance();
            PointsDistance  distance = new PointsDistance(metric);
            ShootingRange   sr       = new ShootingRange(distance);

            Point found = sr.SearchFirstNearest(target, radius);

            CheckHit(found);
            Console.ReadLine();
        }