Exemplo n.º 1
0
        private List <FilmInfo> QuickSort(List <FilmInfo> listToSort)
        {
            if (listToSort.Count <= 1)
            {
                return(listToSort);
            }
            int             pivotIndex = listToSort.Count / 2;
            FilmInfo        pivot      = listToSort[pivotIndex];
            List <FilmInfo> left       = new List <FilmInfo>();
            List <FilmInfo> right      = new List <FilmInfo>();

            for (int i = 0; i < listToSort.Count; i++)
            {
                if (i == pivotIndex)
                {
                    continue;
                }

                if (listToSort[i].Rating <= pivot.Rating)
                {
                    left.Add(listToSort[i]);
                }
                else
                {
                    right.Add(listToSort[i]);
                }
            }

            List <FilmInfo> sorted = QuickSort(left);

            sorted.Add(pivot);
            sorted.AddRange(QuickSort(right));
            return(sorted);
        }
Exemplo n.º 2
0
        public float RateFilm(int filmId, FilmCollection films)
        {
            float    appraisal = 0;
            FilmInfo film      = new FilmInfo();

            film = films.FindFilmById(filmId);
            UserFilmRating userFilmRating = new UserFilmRating(filmId);

            return(appraisal);
        }
Exemplo n.º 3
0
 public void AddFilm(FilmInfo filmToAdd)
 {
     Films.Add(filmToAdd);
 }