Exemple #1
0
        /// <summary>
        /// Static void which is the first methods that is used. It creats the
        /// enumerables to contain the date of the planets and starts. Then, it
        /// calls the class Propreties to know what type of searchthe user
        /// wants.
        /// Then it extracts the file data with Read File and adds to the
        /// enumerables.
        /// After that, it do the search depending of the enumerables and the
        /// propreties the user wants.
        /// In the end, it shows in a table the results of the search.
        /// </summary>
        /// <param name="args">The arguments of the user, used as the method to
        /// know the file and options of the reacher which the user
        /// wants.</param>
        static void Main(string[] args)
        {
            // Enumerables to keep the stars and planets for the search
            IEnumerable <Stars>   stars;
            IEnumerable <Planets> planets;

            // Takes the propreties from args so later on you can filter them
            Propreties propreties = Propreties.ReadArgs(args);

            // Extract data from the file the user wants
            ReadFile file = new ReadFile(propreties.File);

            // Puts the date in the Enumerables
            planets = file.p;
            stars   = file.s;

            // Do the search the defined propreties and the list of stars and/or
            // planets of the file of the user
            Search search = new Search(planets, stars, propreties);

            // Actualizes the Enumerables with the search
            planets = search.planets;
            stars   = search.stars;

            // Shows the what the user searched
            Interface UI = new Interface(planets, stars, propreties);
        }
Exemple #2
0
        /// <summary>
        /// Public constructor that will launch the search process
        /// </summary>
        /// <param name="planets">Planets Information</param>
        /// <param name="stars">Stars Information</param>
        /// <param name="propreties">Proprerties arguments</param>
        /// <return> Returns the actualized the enumerables after the
        /// search </return>
        public Search(IEnumerable <Planets> planets, IEnumerable <Stars> stars,
                      Propreties propreties)
        {
            // Variables
            this.planets    = planets;
            this.stars      = stars;
            this.propreties = propreties;

            // Sees which type of search the user wants with propreties
            switch (propreties.Search)
            {
            case "info":
                // Sees if it's a planet type of search
                if (propreties.Type == "planet")
                {
                    Planet_Info();
                }
                // or a star one
                else
                {
                    Star_Info();
                }
                break;

            case "search":
                Planet_Star_search();
                break;
            }
        }
Exemple #3
0
        /// <summary>
        /// Public constructor to receive the stars and planets enumerables
        /// and print out the search the user wants
        /// </summary>
        /// <param name="planets">Enumerable with the planets</param>
        /// <param name="stars">Enumerable with the stars</param>
        /// <param name="propreties">Propreties of the search</param>
        public Interface(IEnumerable <Planets> planets, IEnumerable <Stars> stars,
                         Propreties propreties)
        {
            // Variables
            this.planets    = planets;
            this.stars      = stars;
            this.propreties = propreties;

            // Sees if csv is requested
            if (propreties.CVS == "on")
            {
                // If it is, then it will show the desired search of the user
                // in format csv that can be printed out in a file if wanted
                if (propreties.Type == "planet")
                {
                    PlanetCVSInterface();
                }
                else
                {
                    StarCVSInterface();
                }
            }
            // If csv is not requested, then it will show the search in a simple
            // table
            else
            {
                if (propreties.Type == "planet")
                {
                    PlanetInterface();
                }
                else
                {
                    StarInterface();
                }
            }
        }