Пример #1
0
        public void ReturnMovie(string movie, string username)
        {
            Node current = root; // search reference
            Node parent  = null; // parent of ptr

            while ((current != null) && (movie.CompareTo(current.Data[0]) != 0))
            {
                parent = current;
                if (movie.CompareTo(current.Data[0]) == 1) // move to the left child of ptr
                {
                    current = current.Left;
                }
                else
                {
                    current = current.Right;
                }
            }

            int oldCop = Int16.Parse(current.Data[7]);

            oldCop++; //convert to int and +1 copy
            string newCop = oldCop.ToString();

            current.Data[7] = newCop;

            //remove movie from user
            MemberCollection.RemoveMovie(movie, username);
        }
Пример #2
0
        public static void StaffMenu()
        {
            //display staff menu
            Console.WriteLine("============Staff Menu==========");
            Console.WriteLine("1. Add a new movie DVD");
            Console.WriteLine("2. Remove a movie DVD");
            Console.WriteLine("3. Register a new Member");
            Console.WriteLine("4. Find a registered member's phone number");
            Console.WriteLine("0. Return to main menu");
            Console.WriteLine("================================");
            Console.Write("\nPlease make a selection (1-4, or 0 to exit): ");
            //bool for invalid selection, repeats switch until valid selection
            bool SwitchBreak = false;

            while (!SwitchBreak)
            {
                switch (Console.ReadLine())
                {
                case "1":
                    new Movie();     //runs movie class to add new movie
                    StaffMenu();     //return to staff menu when done
                    SwitchBreak = true;
                    break;

                case "2":
                    Movie.RemoveMovie();     //removes movie from collection tree in movie class
                    StaffMenu();
                    SwitchBreak = true;
                    break;

                case "3":
                    new Member();     //runs member class to add a new member
                    StaffMenu();
                    SwitchBreak = true;
                    break;

                case "4":
                    MemberCollection.FindNumber();     //searches member collection array for users number
                    StaffMenu();
                    SwitchBreak = true;
                    break;

                case "0":
                    MainMenu();     // exit to main menu
                    SwitchBreak = true;
                    break;

                default:
                    Console.WriteLine("Invalid selection");
                    Console.Write("\nPlease make a selection (1-4, or 0 to exit): ");
                    break;
                }
            }
        }
Пример #3
0
        public void BorrowMovie(string movie, string username)
        {
            Node current = root; // search reference
            Node parent  = null; // parent of ptr

            while ((current != null) && (movie.CompareTo(current.Data[0]) != 0))
            {
                parent = current;
                if (movie.CompareTo(current.Data[0]) == 1) // move to the left child of ptr
                {
                    current = current.Left;
                }
                else
                {
                    current = current.Right;
                }
            }
            // if the search was unsuccessful
            if (current == null)
            {
                Console.WriteLine("Movie is not in our library");
            }
            // if the search was successful
            else
            {
                // check to see if there are any copies
                if (Int16.Parse(current.Data[7]) >= 1)
                {
                    //for copies
                    int oldCop = Int16.Parse(current.Data[7]);
                    oldCop--; //convert to int and -1 copy
                    string newCop = oldCop.ToString();
                    current.Data[7] = newCop;

                    //for popularity
                    int oldPop = Int16.Parse(current.Data[8]);
                    oldPop++; //convert to int and +1 popularity
                    string newPop = oldPop.ToString();
                    current.Data[8] = newPop;

                    //assign movie to user
                    MemberCollection.AssignMovie(movie, username);
                }
                // no copies available
                else
                {
                    Console.WriteLine("Movie is out of stock");
                }
            }
        }
Пример #4
0
        public static void ReturnMovie(string username)
        {
            //ask user input
            Console.Write("Enter the movie you wish to return: ");
            string movie = Console.ReadLine();

            //check to see if user currently has the movie
            if (MemberCollection.CheckIfBorrowed(movie, username))
            {
                //add movie back in collection
                movieCollectionTree.ReturnMovie(movie, username);
            }
            //user does not currently have the movie
            else
            {
                //display
                Console.WriteLine("You are not currently borrowing that movie");
            }
        }
Пример #5
0
        public static void BorrowMovie(string username)
        {
            //ask for user input
            Console.Write("Enter a movie you wish to borrow: ");
            string movie = Console.ReadLine();

            //check to see if already borrowing
            if (MemberCollection.CheckIfBorrowed(movie, username))
            {
                //if borrowing
                Console.WriteLine("You are already borrowing this movie");
            }
            //check to see if already borrowing 10 movies
            else if (MemberCollection.CheckIfMax(username))
            {
                Console.WriteLine("You are already borrowing the max amount of movies");
            }
            //not already borrowing & hasn't borrowed 10 movies
            else
            {
                //borrow movie from collection
                movieCollectionTree.BorrowMovie(movie, username);
            }
        }