예제 #1
0
        public void GetFastestCyclist()
        {
            var steve             = new Cyclist("steve", 1, new double[] { 23, 26, 27 });
            var harvey            = new Cyclist("Harvey", 1.2, new double[] { 25, 26, 21 });
            var john              = new Cyclist("John", 1.5, new double[] { 24, 26, 29 });
            var cyclingTeam       = new Cyclist[] { steve, harvey, john };
            var theFastestCyclist = new FastestCyclist();

            theFastestCyclist = FindFastestCyclist(cyclingTeam);
            Assert.AreEqual(new FastestCyclist(2, "John"), theFastestCyclist);
        }
예제 #2
0
        public FastestCyclist FindFastestCyclist(Cyclist[] cyclingTeam)
        {
            double rotation          = 0;
            var    theFastestCyclist = new FastestCyclist();

            for (int i = 0; i < cyclingTeam.Length; i++)
            {
                for (int j = 0; j < cyclingTeam[i].rotationsPerSecond.Length; j++)
                {
                    if (cyclingTeam[i].rotationsPerSecond[j] > rotation)
                    {
                        theFastestCyclist.name  = cyclingTeam[i].name;
                        theFastestCyclist.index = j;
                        rotation = cyclingTeam[i].rotationsPerSecond[j];
                    }
                }
            }
            return(theFastestCyclist);
        }