示例#1
0
        private static string MemberLogin(MovieCollection movieList, MemberCollection memberList)
        {
            Console.Write("\nEnter username (LastnameFirstname): ");
            string username = Console.ReadLine();

            int userID = -1;

            while (userID < 0)
            {
                for (int i = 0; i < memberList.GetNumMembers(); i++)
                {
                    if (memberList.GetMember(i).GetUsername() == username)
                    {
                        userID = i;
                        break;
                    }
                }
                if (userID < 0)
                {
                    Console.Write("Wrong username! Enter username: "******"Enter Password: "******"Wrong password! Enter password: ");
                inputPass = Console.ReadLine();
            }
            return(username);
        }
示例#2
0
        private static void RemoveMovieStaff2(MovieCollection movieList, MemberCollection memberList)
        {
            Console.Write("Enter movie title: ");
            string removeTitle = Console.ReadLine();
            Movie  checkExist  = null;

            // search only if root is not null
            if (movieList.root != null)
            {
                checkExist = movieList.SearchMovie(movieList.root, removeTitle);
            }

            if (checkExist != null)
            {
                for (int i = 0; i < memberList.GetNumMembers(); i++)
                {
                    memberList.GetMember(i).ReturnDVD(checkExist);
                }
                movieList.Remove(checkExist);
                Console.WriteLine("You removed {0}", checkExist.GetTitle());
            }
            else
            {
                Console.WriteLine("No movies to remove!");
            }
        }
示例#3
0
        private static void AddMemberStaff3(MemberCollection members)
        {
            Console.Write("Enter member's first name: ");
            string first = Console.ReadLine();

            Console.Write("Enter member's last name: ");
            string last = Console.ReadLine();

            // check if user exists
            int memberExists = -1;

            for (int i = 0; i < members.GetNumMembers(); i++)
            {
                Member memberToCheck = members.GetMember(i);
                // already exists
                if (first == memberToCheck.GetFirstName() && last == memberToCheck.GetLastName())
                {
                    memberExists = i;
                    break;
                }
            }
            if (memberExists >= 0) // exist
            {
                Console.WriteLine("{0} {1} has already registered.", first, last);
            }
            else // does not exist
            {
                Console.Write("Enter member's address: ");
                string address = Console.ReadLine();
                Console.Write("Enter member's phone number: ");
                Int32.TryParse(Console.ReadLine(), out int phone);
                Console.Write("Enter member's password (4 digits): ");

                string password = Console.ReadLine();
                int    pass;
                while (!Int32.TryParse(password, out pass) || (pass > 9999 && pass < 0) || password.Length != 4)
                {
                    Console.Write("Needs to be 4 digit : ");
                    password = Console.ReadLine();
                }
                members.RegisterMember(new Member(first, last, address, phone, pass));
            }
        }
示例#4
0
        private static void MemberMenuOptions(MovieCollection movieList, MemberCollection memberList, string user)
        {
            Member loggedInUser = memberList.GetMember(user);

            MemberMenu();
            Int32.TryParse(Console.ReadLine(), out int memberOption);
            switch (memberOption)
            {
            case 1:     // display all dvds
                DisplayAllDVDMember1(movieList);
                MemberMenuOptions(movieList, memberList, user);
                break;

            case 2:     // borrow a dvd
                BorrowDVDMember2(movieList, loggedInUser);
                MemberMenuOptions(movieList, memberList, user);
                break;

            case 3:     // return a dvd
                ReturnDVDMember3(movieList, loggedInUser);
                MemberMenuOptions(movieList, memberList, user);
                break;

            case 4:     // list current borrowed dvd
                ListBorrowedMember4(loggedInUser);
                MemberMenuOptions(movieList, memberList, user);
                break;

            case 5:     // display top 10 most popular dvd
                DisplayTop10Member5(movieList);
                MemberMenuOptions(movieList, memberList, user);
                break;

            case 0:     // return main menu
                MainMenuOptions(MainMenu(), movieList, memberList);
                break;
            }
        }