private string GetTotalCardioDistance()
        {
            int totalDistance = 0;

            for (int outer_it = 0; outer_it < m_registeredTrainingsDays.Count; outer_it++)
            {
                for (int inner_it = 0; inner_it < m_registeredTrainingsDays[outer_it].ExercisesOfTheDay.Count; inner_it++)
                {
                    if (m_registeredTrainingsDays[outer_it].ExercisesOfTheDay[inner_it] is CardioExercise)
                    {
                        CardioExercise temp = m_registeredTrainingsDays[outer_it].ExercisesOfTheDay[inner_it] as CardioExercise;
                        if (temp != null)
                        {
                            totalDistance += temp.Distance;
                        }
                    }
                }
            }

            if (totalDistance > 1000)
            {
                return(Convert.ToString(Math.Round((double)(totalDistance / 1000), 0, MidpointRounding.ToEven)) + " km  " + totalDistance % 1000 + " m");
            }
            else
            {
                return(totalDistance + " m");
            }
        }
        private string GetTotalCardioDuration()
        {
            Duration totalDuration = new Duration();

            for (int outer_it = 0; outer_it < m_registeredTrainingsDays.Count; outer_it++)
            {
                for (int inner_it = 0; inner_it < m_registeredTrainingsDays[outer_it].ExercisesOfTheDay.Count; inner_it++)
                {
                    if (m_registeredTrainingsDays[outer_it].ExercisesOfTheDay[inner_it] is CardioExercise)
                    {
                        CardioExercise temp = m_registeredTrainingsDays[outer_it].ExercisesOfTheDay[inner_it] as CardioExercise;
                        if (temp != null)
                        {
                            totalDuration += temp.ExerciseDuration;
                        }
                    }
                }
            }
            return(totalDuration.DurationToDimensionString());
        }
        private string FindMostTrainedExercise(EtypeOfExercise exerciseType)
        {
            string mostTrainedExercise = "Not trained yet";
            int    timesTrained        = 0;
            int    temp = 0;

            if (exerciseType == EtypeOfExercise.MachineExercise)
            {
                for (int outer_it = 0; outer_it < m_registeredTrainingsDays.Count; outer_it++)
                {
                    for (int inner_it = 0; inner_it < m_registeredTrainingsDays[outer_it].ExercisesOfTheDay.Count; inner_it++)
                    {
                        if (m_registeredTrainingsDays[outer_it].ExercisesOfTheDay[inner_it] is MachineExcercise)
                        {
                            MachineExcercise tempExercise = m_registeredTrainingsDays[outer_it].ExercisesOfTheDay[inner_it] as MachineExcercise;

                            if (tempExercise != null)
                            {
                                timesTrained = getHowManyTimesTrained(tempExercise.ExerciseName);
                                if (timesTrained > temp)
                                {
                                    mostTrainedExercise = tempExercise.ExerciseName;
                                    temp = timesTrained;
                                }
                            }
                        }
                    }
                }
            }
            else if (exerciseType == EtypeOfExercise.CardioExercise)
            {
                for (int outer_it = 0; outer_it < m_registeredTrainingsDays.Count; outer_it++)
                {
                    for (int inner_it = 0; inner_it < m_registeredTrainingsDays[outer_it].ExercisesOfTheDay.Count; inner_it++)
                    {
                        if (m_registeredTrainingsDays[outer_it].ExercisesOfTheDay[inner_it] is CardioExercise)
                        {
                            CardioExercise tempExercise = m_registeredTrainingsDays[outer_it].ExercisesOfTheDay[inner_it] as CardioExercise;

                            if (tempExercise != null)
                            {
                                timesTrained = getHowManyTimesTrained(tempExercise.ExerciseName);
                                if (timesTrained > temp)
                                {
                                    mostTrainedExercise = tempExercise.ExerciseName;
                                    temp = timesTrained;
                                }
                            }
                        }
                    }
                }
            }
            else if (exerciseType == EtypeOfExercise.BodyWeightExercise)
            {
                for (int outer_it = 0; outer_it < m_registeredTrainingsDays.Count; outer_it++)
                {
                    for (int inner_it = 0; inner_it < m_registeredTrainingsDays[outer_it].ExercisesOfTheDay.Count; inner_it++)
                    {
                        if (m_registeredTrainingsDays[outer_it].ExercisesOfTheDay[inner_it] is BodyWeightExercise)
                        {
                            BodyWeightExercise tempExercise = m_registeredTrainingsDays[outer_it].ExercisesOfTheDay[inner_it] as BodyWeightExercise;

                            if (tempExercise != null)
                            {
                                timesTrained = getHowManyTimesTrained(tempExercise.ExerciseName);
                                if (timesTrained > temp)
                                {
                                    mostTrainedExercise = tempExercise.ExerciseName;
                                    temp = timesTrained;
                                }
                            }
                        }
                    }
                }
            }
            else if (exerciseType == EtypeOfExercise.BodyWeightExercise)
            {
                throw new NotImplementedException();
            }

            return(mostTrainedExercise);
        }
예제 #4
0
        public void addCardioExcercise(string trainingName, string comment, int distance, Duration trainingTime)
        {
            CardioExercise cardioExcercise = new CardioExercise(trainingName, comment, distance, trainingTime);

            m_exercisesOfTheDay.Add(cardioExcercise);
        }