Exemplo n.º 1
0
    public static int Main(string[] args)
    {
        MathLog log = new MathLog();
        TestLibrary.TestFramework.BeginTestCase("Testing System.Math.Log(System.Double)...");

        if (log.RunTests())
        {
            TestLibrary.TestFramework.EndTestCase();
            TestLibrary.TestFramework.LogInformation("PASS");
            return 100;
        }
        else
        {
            TestLibrary.TestFramework.EndTestCase();
            TestLibrary.TestFramework.LogInformation("FAIL");
            return 0;
        }
    }
Exemplo n.º 2
0
    public static int Main(string[] args)
    {
        MathLog log = new MathLog();

        TestLibrary.TestFramework.BeginTestCase("Testing System.Math.Log(System.Double)...");

        if (log.RunTests())
        {
            TestLibrary.TestFramework.EndTestCase();
            TestLibrary.TestFramework.LogInformation("PASS");
            return(100);
        }
        else
        {
            TestLibrary.TestFramework.EndTestCase();
            TestLibrary.TestFramework.LogInformation("FAIL");
            return(0);
        }
    }
Exemplo n.º 3
0
 public void Update(MathLog Entitie)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 4
0
 public List <MathLog> ListThreFriends(MathLog Entitie)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 public void Add(MathLog Entitie)
 {
     _MathLogInterface.Add(Entitie);
 }
Exemplo n.º 6
0
        public List <Friend> ListThreFriends(Friend newFriend)
        {
            var friends = _FriendInterface.List();
            List <FriendDistance> listFriendDistances = new List <FriendDistance>();
            List <Friend>         ThreFriends         = new List <Friend>();
            MathLog mathLog = new MathLog();

            foreach (var friend in friends)
            {
                FriendDistance friendDistance = new FriendDistance();

                var x1 = newFriend.Latitude;
                var x2 = friend.Latitude;

                var y1 = newFriend.Longitude;
                var y2 = friend.Longitude;

                var x = x2 - x1;
                var y = y2 - y1;

                var sx = x * x;
                var sy = y * y;

                var sum = sx + sy;

                var distance = Math.Sqrt(sum);

                friendDistance.friend   = friend;
                friendDistance.distance = distance;
                listFriendDistances.Add(friendDistance);

                mathLog.NewFriendId        = newFriend.Id;
                mathLog.NewFriendName      = newFriend.Name;
                mathLog.NewFriendLatitude  = newFriend.Latitude;
                mathLog.NewFriendLongitude = newFriend.Longitude;
                mathLog.FriendId           = friend.Id;
                mathLog.FriendName         = friend.Name;
                mathLog.FriendLatitude     = friend.Latitude;
                mathLog.FriendLongitude    = friend.Longitude;
                mathLog.Distance           = distance;
            }

            List <FriendDistance> orderList = listFriendDistances.OrderBy(friend => friend.distance).ToList();

            var count = 0;

            foreach (var obj in orderList)
            {
                if ((count < 3))
                {
                    if (obj.distance != 0)
                    {
                        ThreFriends.Add(obj.friend);
                        count++;
                    }
                }
                else
                {
                    break;
                }
            }

            return(ThreFriends);
        }