Exemplo n.º 1
0
        /// <summary>
        /// Dispaly movies in collection
        /// </summary>
        /// <param name="DVDS"></param>
        private static void display(MovieCollection DVDS)
        {
            Console.WriteLine("\n\n===========================================");

            Movie[] a = DVDS.ToArray();
            if (a.Length == 0)
            {
                Console.WriteLine("collection is empty!");
                return;
            }
            foreach (Movie m in a)
            {
                Console.WriteLine(m.toString());
            }
        }
Exemplo n.º 2
0
        private static void staffMenu(ref MovieCollection DVDS, ref MemberCollection members)
        {
            string[] Genres = { "Drama",  "Adventure", "Family",   "Action", "Sci-Fi",
                                "Comedy", "Animated",  "Thriller", "Other" };
            string[] Classifications = { "General (G)",   "Parental Guidance (PG)",
                                         "Mature (M15+)", "Mature Accompanied (MA15+)" };
            string   title;
            int      numberOfCopies;
            string   starring;
            string   director;
            int      duration;
            string   genre;
            string   releaseDate;
            string   classification;
            string   firstName;
            string   lastName;
            string   phoneNumber;
            string   residentialAddress;
            string   password;



            bool exist = false;

            while (!exist)
            {
                Console.Write("\n\n===============Staff Menu==================\n" +
                              "1. Add a new Movie DVD.\n" +
                              "2. Remove a Movie DVD.\n" +
                              "3. Display all movies.\n" +
                              "4. Register a new Member.\n" +
                              "5. Find a registered member's phone number.\n" +
                              "6. Display members.\n" +
                              "0. return to main menu.\n" +
                              "===========================================\n" +
                              "Please make a Selection(1-6, or 0 to exist):");
                int key;
                if (int.TryParse(Console.ReadLine(), out key) && key < 7)
                {
                    if (key == 0)
                    {
                        exist = true;
                    }

                    if (key == 1)
                    {
                        Console.Write("Enter Movie Title: ");
                        title = Console.ReadLine();
                        Movie[] movieArray  = DVDS.ToArray();
                        bool    movieExists = false;
                        foreach (Movie m in movieArray)
                        {
                            if (string.Compare(m.title.ToUpper().Replace(" ", string.Empty)
                                               , title.ToUpper().Replace(" ", string.Empty)) == 0)
                            {
                                movieExists = true;
                                break;
                            }
                        }
                        if (movieExists)
                        {
                            Console.WriteLine("Movie aleady exists!");
                            Console.Write("Enter number of copies: ");
                            while (!int.TryParse(Console.ReadLine(), out numberOfCopies))
                            {
                                Console.WriteLine("invalid input");
                                Console.Write("Enter number of copies: ");
                            }
                            DVDS.addCpies(title, numberOfCopies);
                        }
                        else
                        {
                            Console.Write("Enter number of copies: ");
                            while (!int.TryParse(Console.ReadLine(), out numberOfCopies))
                            {
                                Console.WriteLine("invalid input");
                                Console.Write("Enter number of copies: ");
                            }
                            Console.Write("Enter release date (year): ");
                            releaseDate = Console.ReadLine();
                            Console.Write("Enter Starring actor/s: ");
                            starring = Console.ReadLine();
                            Console.Write("Enter Director/s: ");
                            director = Console.ReadLine();
                            Console.Write("Enter Duration (minutes): ");
                            while (!int.TryParse(Console.ReadLine(), out duration))
                            {
                                Console.WriteLine("invalid input");
                                Console.Write("Enter Duration (minutes): ");
                            }
                            Console.WriteLine("Select Genre: ");
                            int i = 1;
                            foreach (string g in Genres)
                            {
                                Console.WriteLine(i + ". " + g);
                                i++;
                            }

                            Console.Write("Enter selection(1-{0}): ", Genres.Length);
                            int selction;
                            while (!int.TryParse(Console.ReadLine(), out selction) || selction > Genres.Length || selction <= 0)
                            {
                                Console.WriteLine("invalid input");
                                Console.Write("Enter selection(1-{0}): ", Genres.Length);
                            }
                            genre = Genres[selction - 1];



                            Console.WriteLine("Select Classifaction: ");
                            i = 1;
                            foreach (string c in Classifications)
                            {
                                Console.WriteLine(i + ". " + c);
                                i++;
                            }
                            selction = Classifications.Length;
                            Console.Write("Enter selection(1-{0}): ", Classifications.Length);
                            while (!int.TryParse(Console.ReadLine(), out selction) || selction > Classifications.Length || selction <= 0)
                            {
                                Console.WriteLine("invalid input");
                                Console.Write("Enter selection(1-{0}): ", Classifications.Length);
                            }
                            classification = Classifications[selction - 1];
                            DVDS.Add(new Movie(title, numberOfCopies, genre, duration, releaseDate, starring,
                                               director, classification));
                        }
                    }
                    if (key == 2)
                    {
                        Console.Write("Enter title of movie to remove: ");
                        DVDS.Remove(Console.ReadLine());
                    }
                    if (key == 3)
                    {
                        display(DVDS);
                    }
                    if (key == 4)
                    {
                        Console.Write("Enter First name: ");
                        firstName = Console.ReadLine().Replace(" ", string.Empty);

                        Console.Write("Enter last name: ");
                        lastName = Console.ReadLine().Replace(" ", string.Empty);


                        int    number;
                        string contractnumber;
                        bool   successful = false;
                        do
                        {
                            Console.Write("Enter Contact number: ");
                            contractnumber = Console.ReadLine();
                            if (int.TryParse(contractnumber, out number))
                            {
                                successful = true;
                            }
                            else
                            {
                                Console.WriteLine("invalid input");
                            }
                        } while (!successful);
                        phoneNumber = contractnumber;

                        Console.Write("Enter Address: ");
                        residentialAddress = Console.ReadLine();


                        string input;
                        int    psw;
                        successful = false;
                        do
                        {
                            Console.Write("Enter Password(4 digit integer): ");
                            input = Console.ReadLine();
                            if (input.Length == 4 && int.TryParse(input, out psw))
                            {
                                successful = true;
                            }
                            else
                            {
                                Console.WriteLine("invalid input");
                            }
                        } while (!successful);

                        password = input;

                        members.Register(firstName, lastName, phoneNumber, residentialAddress, password);
                    }
                    if (key == 5)
                    {
                        Console.Write("Enter username(Last Name + First Name): ");
                        members.FindContactNumber(Console.ReadLine());
                    }
                    if (key == 6)
                    {
                        Console.WriteLine("Members in Library:");
                        foreach (Member m in members.members)
                        {
                            Console.WriteLine(m.toString());
                        }
                    }
                }
                else
                {
                    Console.WriteLine("invalid input");
                }
            }
        }