예제 #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 MainMenuOptions(int option, MovieCollection movieList, MemberCollection memberList)
        {
            switch (option)
            {
            case 1:
                // login method
                bool staffLoggedIn = StaffLogin(new Staff("staff", "today123"));
                if (staffLoggedIn)
                {
                    StaffMenuOptions(movieList, memberList);
                }
                break;

            // member login
            case 2:
                if (memberList.GetNumMembers() > 0)
                {
                    string user = MemberLogin(movieList, memberList);
                    MemberMenuOptions(movieList, memberList, user);
                }
                else
                {
                    Console.WriteLine("No members registered!");
                    MainMenuOptions(MainMenu(), movieList, memberList);
                }
                break;

            default:
                // user press 0 to exit
                Console.WriteLine("Goodbye!");
                break;
            }
        }
예제 #3
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!");
            }
        }
예제 #4
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));
            }
        }