Example #1
0
        /*
         * paramters:
         * Movies = This is the movie collection to be passed down and accessed throughout the program
         * Members = This is to be passed down to be be accessed throughout the program
         *
         * displays the Main Menu and allows staff or members to traverse through the system.
         *
         * returns: Nothing
         */

        static void MENU(MovieCollection Movies, MemberCollection Members)
        {
            int truth = 1;

            while (truth >= 1)
            {
                truth = 1;
                Console.Clear();
                Console.WriteLine("Welcome to the Community Library");
                Console.WriteLine("============Main Menu===========");
                Console.WriteLine("1. Staff Login");
                Console.WriteLine("2. Member Login");
                Console.WriteLine("0. Exit");
                Console.WriteLine("================================");
                Console.Write("Please make a selection (1-2, 0 to exit): ");
                string value = Console.ReadLine();

                try
                {
                    int result = Convert.ToInt32(value);
                    truth = SWITCHMENU(result, Movies, Members);
                }
                catch { Console.WriteLine("ERROR: Please try again"); }
                Console.WriteLine("Please press any key to continue...");

                if (truth == 1)
                {
                    Console.ReadLine();
                }
                Console.Clear();
            }
        }
Example #2
0
        /*
         * parameters:
         * result = an integer value to determine the switchcase
         * Movies = The Binary Search Tree to be passed down and accessed.
         * Members = The array of members to be passed and accessed.
         *
         * This allows staff and members to traverse throughout the program, depending on the choosen number value they have inputted.
         *
         * returns: int = To determine readline status on the 'MENU' method.
         *
         */
        public static int SWITCHMENU(int result, MovieCollection Movies, MemberCollection Members)
        {
            int release;

            switch (result)
            {
            case 1:
                Console.Clear();
                Staff.LOGIN(Movies, Members);
                release = 2;
                break;

            case 2:
                Console.Clear();
                Member.Login(Members, Movies);
                release = 2;
                break;

            case 0:
                release = 0;
                break;

            default:
                throw new Exception();
            }
            return(release);
        }
Example #3
0
        /*
         * parameters:
         * Members = The array of members to be passed and accessed.
         *
         * This displays the MemberSearch function where it takes an input and searches through the
         * MemberCollection array for contact details depending on the name given.
         *
         * returns: nothing
         */

        public static void MemberSearch(MemberCollection Members)
        {
            Console.Clear();
            Members.DisplayMembers();
            bool SearchCatch = true;

            while (SearchCatch)
            {
                SearchCatch = false;
                Console.Write("Enter Member's Fullname to 'search' for Contact Information or press 'ENTER' to exit: ");
                string name = Console.ReadLine();
                try
                {
                    if (name != "")
                    {
                        Console.Clear();
                        Members.DisplayNumber(name);
                        Console.WriteLine("");
                        Console.WriteLine("press 'ENTER' to continue");
                        Console.ReadLine();
                    }
                }
                catch { Console.WriteLine("ERROR: Please enter valid input"); SearchCatch = true; }
            }
        }
Example #4
0
        /*
         * paramters: None
         *
         * Runs main and executes the program.
         *
         * returns: Nothing
         */
        static void Main()
        {
            MovieCollection  Movies  = new MovieCollection();
            MemberCollection Members = new MemberCollection();

            MENU(Movies, Members);
        }
Example #5
0
        private static void GetMembersPhoneNumber()
        {
            Console.Clear();

            // Search MemberCollection array for a matching user by full name
            Console.Write("\r\nPlease enter the full name of the user to find their phone number: ");

            String name = Console.ReadLine();

            String phoneNumber = MemberCollection.GetPhoneNumber(name);

            if (phoneNumber == null)
            {
                Console.Clear();

                Console.WriteLine("Couldn't find a user by that name! Press Enter to return to staff menu... ");

                while (Console.ReadKey().Key != ConsoleKey.Enter)
                {
                }
            }
            else
            {
                Console.Clear();

                Console.WriteLine("The phone number associated with {0} is: \r\n\r\n" +
                                  "\t{1}\r\n\r\n" +
                                  "Press Enter to return to staff menu... ", name, phoneNumber);

                while (Console.ReadKey().Key != ConsoleKey.Enter)
                {
                }
            }
        }
Example #6
0
        /*
         * parameters:
         * Movies = This is the movie collection to be passed down and accessed within the Staff class
         * Members = This is to be passed down to be be accessed within the Staff class
         *
         * This displays the Staff Menu options, and this also reads the input of the staff member.
         *
         * returns: nothing
         *
         */

        static void STAFF(MovieCollection Movies, MemberCollection Members)
        {
            Console.Clear();
            bool truth = true;

            while (truth)
            {
                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("Please make a selection (1-4, 0 to exit): ");
                string value = Console.ReadLine();

                try
                {
                    int result = Convert.ToInt32(value);
                    truth = SWITCHSTAFF(result, Movies, Members);
                }
                catch { Console.WriteLine("ERROR: Please try again"); Console.WriteLine("Please press 'Enter' to continue..."); Console.ReadLine(); }
                Console.Clear();
            }
        }
Example #7
0
        /*
         * parameters:
         * result = an integer value to determine the switchcase
         * Movies = The Binary Search Tree to be passed down and accessed.
         * Members = The array of members to be passed and accessed.
         *
         * This allows staff to traverse throughout the staff menu, depending on the choosen number value they have inputted.
         *
         * returns: int = To determine readline status on the 'MENU' method.
         */

        public static bool SWITCHSTAFF(int result, MovieCollection Movies, MemberCollection Members)
        {
            switch (result)
            {
            case 1:
                AddMovie(Movies);
                break;

            case 2:
                RemoveMovie(Movies);
                break;

            case 3:
                RegisterMember(Members);
                break;

            case 4:
                MemberSearch(Members);
                break;

            case 0:
                return(false);

            default:
                throw new Exception();
            }
            return(true);
        }
        private static void RunRentalSystem()
        {
            MovieCollection  = new MovieCollection();
            MemberCollection = new MemberCollection(MaxMembers);

            while (true)
            {
                Console.Clear();
                switch (WriteWelcome())
                {
                case 0:
                    break;

                case 1:
                    Console.Clear();
                    if (StaffLogin())
                    {
                        Console.Clear();
                        StaffMenu();
                    }
                    else
                    {
                        Console.Clear();
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Incorrect Username or Password!\r\n");
                        Console.ResetColor();

                        Console.WriteLine("Press enter to return to main menu... ");

                        while (Console.ReadKey().Key != ConsoleKey.Enter)
                        {
                        }
                    }
                    break;

                case 2:
                    Console.Clear();
                    Member member = MemberLogin();
                    if (member != null)
                    {
                        Console.Clear();
                        MemberMenu(member);
                    }
                    else
                    {
                        Console.Clear();
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Incorrect Username or Password!\r\n");
                        Console.ResetColor();

                        Console.WriteLine("Press enter to return to main menu... ");

                        while (Console.ReadKey().Key != ConsoleKey.Enter)
                        {
                        }
                    }
                    break;
                }
            }
        }
Example #9
0
        /*
         * parameters:
         * Members = The array of members to be passed and accessed.
         *
         * This displays the RegisterMember function where several inputs are taken to create a new Member
         *
         * returns: nothing
         */
        public static void RegisterMember(MemberCollection Members)
        {
            bool truth = true;

            while (truth)
            {
                Console.Clear();
                Console.WriteLine("============Add Member==========");
                string GivenName          = LoopCheck("Enter Given Name: ");
                string Surname            = LoopCheck("Enter Surname: ");
                string ResidentialAddress = LoopCheck("Enter Residential Address: ");
                string PhoneNumber        = "";

                bool NumberCatch = true;
                while (NumberCatch)
                {
                    NumberCatch = false;
                    Console.Write("Enter valid Phone Number: ");
                    string number = Console.ReadLine();

                    try { Int32.Parse(number); PhoneNumber = number; } catch { Console.WriteLine("ERROR: Please enter valid input"); NumberCatch = true; }
                }

                bool RestartCatch = true;
                while (RestartCatch)
                {
                    RestartCatch = false;
                    Console.Write("Restart (0), Add (1): ");
                    string restart = Console.ReadLine();
                    try
                    {
                        int value = Int32.Parse(restart);
                        if (value == 0)
                        {
                            truth = true;
                        }
                        else if (value == 1)
                        {
                            if (Members.Insert(new Member(GivenName, Surname, ResidentialAddress, PhoneNumber)))
                            {
                                Console.WriteLine();
                                Console.WriteLine(String.Format("Member '{0} {1}' has been added press 'ENTER' to continue", GivenName, Surname));
                            }
                            Console.ReadLine();
                            truth = false;
                        }
                        else
                        {
                            throw new Exception();
                        }
                    }
                    catch { Console.WriteLine("ERROR: Please enter valid input"); RestartCatch = true; }
                }
            }
        }
Example #10
0
        /*
         * paramters:
         * Movies = This is the movie collection to be passed down and accessed within the Staff class
         * Members = This is to be passed down to be be accessed within the Staff class
         *
         * Authentication for logging into the Staff menu.
         *
         * returns: nothing
         *
         */
        public static void LOGIN(MovieCollection Movies, MemberCollection Members)
        {
            Console.WriteLine("Welcome to the Community Library");
            Console.WriteLine("============Staff Login===========");
            Console.WriteLine("Please Enter Credentials");
            Console.WriteLine("");
            Console.Write("Username: "******"Password: "******"ERROR: Incorrect Credentials"); Console.ReadLine(); }
            Console.Clear();
        }
Example #11
0
        private static void RegisterNewMember()
        {
            Console.Clear();

            // Get full name of member and make username from it
            Console.Write("\r\nPlease enter the first name of the member: ");
            String firstName = Console.ReadLine();

            Console.Write("\r\nPlease enter the last name of the member: ");
            String fullName = firstName + " " + Console.ReadLine();
            String userName = fullName.Split(' ').Last() + fullName.Split(' ').First();

            // Get members address
            Console.Write("\r\nPlease enter the members address: ");
            String address = Console.ReadLine();

            Console.Write("\r\nPlease enter the members phone number: ");
            String phoneNumber = Console.ReadLine();

            Console.Write("\r\nPlease have the member enter their 4 digit passcode: ");
            int passCode = 0;

            while (!int.TryParse(Console.ReadLine(), out passCode) || passCode.ToString().Length != 4)
            {
                Console.WriteLine("\r\nPlease enter a valid, 4 digit passcode!");
            }

            Member newMember = new Member(fullName, userName, passCode, address, phoneNumber);

            MemberCollection.AddMember(newMember);

            Console.Clear();

            Console.WriteLine("{0} added to the system. Username is: {1}\r\n" +
                              "Press enter to return to staff menu... ", fullName, userName);

            while (Console.ReadKey().Key != ConsoleKey.Enter)
            {
            }
        }
Example #12
0
        /*
         * paramater:
         * Movies = This is the movie collection to be passed down and accessed for the particular member
         * Members = This is to be passed down to be be accessed for a particular member
         *
         * Checks if the member already has a password.
         *
         * return: bool = true or false to determine if the password has already been set.
         */

        public static void Login(MemberCollection Members, MovieCollection Movies)
        {
            bool flag = false;

            Console.WriteLine("Welcome to the Community Library");
            Console.WriteLine("============Member Login===========");
            Console.WriteLine("Please Enter Credentials");
            Console.WriteLine("");
            Member logged;

            string user = Staff.LoopCheck("Username (LastnameFirstname): ");
            string pass = "";

            logged = Members.UserSearch(user);

            try {
                if (logged.PassRego())
                {
                    string value = "";
                    bool   link  = true;
                    while (link)
                    {
                        link = false;
                        Console.Write("Set New Password (Must be 4 digits): ");
                        value = Console.ReadLine();
                        try
                        {
                            if (value == "")
                            {
                                throw new Exception();
                            }
                            else
                            {
                                if (value.Length != 4)
                                {
                                    throw new Exception();
                                }
                                else
                                {
                                    Int32.Parse(value);
                                    pass = value;
                                }
                            }
                        }
                        catch { Console.WriteLine("ERROR: Please enter 4 digits"); link = true; }
                    }
                }
                else
                {
                    pass = Staff.LoopCheck("Enter Password: "******"User '{0}' not found", user)); flag = true; }

            if (!flag)
            {
                if (logged.PasswordCheck(pass))
                {
                    Console.WriteLine(String.Format("Succesfully Logged in, Welcome {0}, press 'ENTER' to continue", logged.FullName));
                    Console.ReadLine();
                    logged.MEMBER(Movies);
                }
                else
                {
                    Console.WriteLine("Password Incorrect press 'ENTER' to exit");
                    Console.ReadLine();
                }
            }
            else
            {
                Console.ReadLine();
            }
            Console.Clear();
        }
Example #13
0
        /*
         * paramters:
         * user = The username field.
         * pass = The password field.
         * Movies = This is the movie collection to be passed down and accessed within the Staff class
         * Members = This is to be passed down to be be accessed within the Staff class
         *
         * This is to validate if the provided inputs are correct.
         *
         * returns: nothing
         */

        public static void LOGINCHECK(string user, string pass, MovieCollection Movies, MemberCollection Members)
        {
            if (user == "staff" && pass == "today123")
            {
                STAFF(Movies, Members);
            }
            else
            {
                throw new Exception();
            }
        }