MovieLister Class – .Net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MovieFinderTestSpring.Net
{
    public class MovieLister
    {
        private static int lastVersionID = 0;
        private readonly int versionID;

        public int VersionID { get { return versionID; } }

        private IMovieFinder Finder { get; set; }

        public MovieLister(IMovieFinder finder)
            : this()
        {
            this.Finder = finder;
        }

        public MovieLister()
        {
            this.versionID = ++MovieLister.lastVersionID;
        }

        public Movie[] MoviesDirectedBy(String director)
        {
            List<Movie> allMovies = Finder.FindAll();
            List<Movie> movies = new List<Movie>();
            foreach (Movie movie in allMovies)
            {
                if (movie.Director == director)
                    movies.Add(movie);
            }
            return movies.ToArray<Movie>();
        }
    }
}
 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s