예제 #1
0
파일: mathlog.cs 프로젝트: CheneyWu/coreclr
    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;
        }
    }
예제 #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);
        }
    }
예제 #3
0
 public void Update(MathLog Entitie)
 {
     throw new NotImplementedException();
 }
예제 #4
0
 public List <MathLog> ListThreFriends(MathLog Entitie)
 {
     throw new NotImplementedException();
 }
예제 #5
0
 public void Add(MathLog Entitie)
 {
     _MathLogInterface.Add(Entitie);
 }
예제 #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);
        }