Exemple #1
0
        // This method is a very important method that how we identify member in a Club, it takes in a Club but,
        // we should be able to overload it if logically it makes more sense to use the entire list of clubs as the parameter
        public Member FindMemberByIDLoop()
        {
            int  num = 0;
            bool isANum;
            bool runSearch = true;
            bool isMulti   = false;

            Member single = new SingleClubMember();
            Member multi  = new MultiClubMember();


            while (runSearch)
            {
                Console.WriteLine("Please enter member's ID:");
                string input = ReadAndReturnInput();
                isANum = int.TryParse(input, out num);

                if (isANum == true)
                {
                    foreach (Member searchingForMember in ListOfMembers.ToArray()) // This represents the active Club the emplyee is accessing from
                    {
                        if (searchingForMember.ID == num)
                        {
                            if (searchingForMember.GetType().Equals(single.GetType()))
                            {
                                single    = searchingForMember;
                                isMulti   = false;
                                runSearch = false;
                                return(single);
                            }
                            else if (searchingForMember.GetType().Equals(multi.GetType()))
                            {
                                multi   = searchingForMember;
                                isMulti = true;
                                return(multi);
                            }
                        }
                        else
                        {
                            Console.WriteLine("Error ID Number not found at this location!");
                            runSearch = false;
                        }
                    }
                    //----------------------------------------------------------------------------------------------------------------------
                }
                else if (!isANum)
                {
                    Console.WriteLine("I'm sorry, that is not a valid ID number. Please try again.");
                }
            }
            return(single);
        }
Exemple #2
0
        // This method below is the primary Add Member logic that will be used by the User Interface Logic (switch statement)
        public void AddMemberToClub()
        {
            int i = 0;

            Console.WriteLine($"\nWhich club would you like to be a member of? Please enter 1 through {ListOfClubs.Instance.ClubList.Count}\n");
            foreach (Club c in ListOfClubs.Instance.ClubList) //listing clubs for user to choose
            {
                i++;
                Console.WriteLine($"{i}. {c.Name}");
            }
            Console.WriteLine($"0. Multi-club membership"); //or choose a multiclub membership
            i = 0;
            string input = Console.ReadLine().Trim();

            if (!int.TryParse(input, out int userChoice))
            {
                Console.WriteLine($"That is not a number. Please enter 1 through {ListOfClubs.Instance.ClubList.Count}");
                AddMemberToClub();
            }
            else if (userChoice <= 0 || userChoice > ListOfClubs.Instance.ClubList.Count && userChoice != 6)
            {
                Console.WriteLine($"That is not an option. Please enter 1 through {ListOfClubs.Instance.ClubList.Count}");
                AddMemberToClub();
            }
            else
            {
                userChoice = int.Parse(input);
                Console.WriteLine("\nWhat is the member's first name?");
                string newName = Console.ReadLine().Trim();
                Console.WriteLine("\nWhat is the member's last name?");
                string newLastName = Console.ReadLine().Trim();
                Console.WriteLine("\nWhat is the member ID?\n");
                int newId = int.Parse(Console.ReadLine().Trim());
                foreach (Club c in ListOfClubs.Instance.ClubList) //adding a single club member
                {
                    i++;
                    if (userChoice == i) //choosing by int index (i)
                    {
                        Console.WriteLine($"New Member: {newName} {newLastName} added to {c.Name} with ID: {newId}");
                        Member newSingleMember = new SingleClubMember(newId, newName, newLastName, c);
                        ListOfMembers.Add(newSingleMember);
                    }
                }
                if (userChoice == 0) //or adding a multiclub member
                {
                    Console.WriteLine($"New Member: {newName} {newLastName} added as a multi-club member with ID: {newId}");
                    Member newMultiMember = new MultiClubMember(newId, newName, newLastName, 0);
                    ListOfMembers.Add(newMultiMember);
                }
            }
        }
Exemple #3
0
        public void CreateMembersFromFile()
        {
            string[] allFileLines = File.ReadAllLines("../../../Members.txt");
            string   clubName     = null;
            Club     targetClub   = GlobalFindClubByName(clubName);

            string numSign = "#";

            foreach (string fileLine in allFileLines)
            {
                if (fileLine != null)
                {
                    if (fileLine.StartsWith("Club Name:"))
                    {
                        clubName   = fileLine.Remove(0, 11);
                        targetClub = GlobalFindClubByName(clubName);
                    }

                    if (fileLine.StartsWith("Member:"))
                    {
                        string memberName       = fileLine.Substring(8);
                        string memberClubAssign = fileLine.Substring(fileLine.IndexOf('@') + 1);
                        if (fileLine.Contains('#'))
                        {
                            memberName       = memberName.Remove(memberName.IndexOf('#'));
                            memberClubAssign = memberClubAssign.Remove(memberClubAssign.IndexOf('#'));
                        }
                        if (fileLine.Contains('@'))
                        {
                            memberName = memberName.Remove(memberName.IndexOf('@'));
                        }

                        int  memberId;
                        bool isNum = int.TryParse(fileLine.Substring(fileLine.IndexOf('#') + 1), out memberId);

                        Member writingMember = new SingleClubMember(memberId, memberName, GlobalFindClubByName(memberClubAssign));
                        targetClub.AddMemberToClub(writingMember);
                    }
                }
            }
        }
        public static void CancelMembership()
        {
            var  club           = new Club();
            bool cancellingMems = true;

            while (cancellingMems)

            {
                Console.WriteLine("");
                Console.WriteLine("Begin the membership cancellation process by entering a member ID or NAME.\nWhich would you like to enter? (ID/NAME)");
                string decision = Console.ReadLine().Trim().ToLower();
                if (decision == "id")
                {
                    Member member1 = new SingleClubMember();
                    Member member2 = new MultiClubMember();

                    Console.WriteLine("\nPlease input the member's ID number: ");
                    string input  = ReadAndReturnInput();
                    int    num    = 0;
                    bool   isANum = int.TryParse(input, out num);

                    if (isANum)
                    {
                        if (num == member1.ID || num == member2.ID)
                        {
                            if (member1.ID == num)
                            {
                                Console.WriteLine("");
                                club.RemoveMemberFromClub(member1, num);
                                Console.WriteLine($"This membership has been located and cancelled successfully, and you'll be returned to the Modify Member Status Menu.");
                                Console.WriteLine("");
                                cancellingMems = false;
                            }
                            else if (member2.ID == num)
                            {
                                Console.WriteLine("");
                                club.RemoveMemberFromClub(member2, num);
                                Console.WriteLine($"This membership has been located and cancelled successfully, and you'll be returned to the Modify Member Status Menu.");
                                Console.WriteLine("");
                                cancellingMems = false;
                            }
                        }
                        else
                        {
                            Console.WriteLine("I'm sorry, I could not locate a member with that ID number. Would you like to try cancelling this membership again? (Y/N)");
                            string goAgainChoice = Console.ReadLine().Trim().ToLower();
                            if (goAgainChoice == "y" || goAgainChoice == "yes")
                            {
                                cancellingMems = true;
                            }
                            else if (goAgainChoice == "n" || goAgainChoice == "no")
                            {
                                cancellingMems = false;
                            }
                            else
                            {
                                Console.WriteLine("I'm sorry, I can only accept yes or no responses. Please try again.");
                                cancellingMems = true;
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("I'm sorry, I did not recognize a number there. Please try again.");
                        cancellingMems = true;
                    }
                }
                else if (decision == "name")
                {
                    Member member1 = new SingleClubMember();
                    Member member2 = new MultiClubMember();
                    Console.WriteLine("\nPlease input the member's full name: ");
                    string input = ReadAndReturnInput();

                    if (member1.Name == input)
                    {
                        Console.WriteLine("");
                        club.RemoveMemberFromClubByName(member1, input);
                        Console.WriteLine("This membership has been located and succesfully cancelled, and you'll be returned to the Modify Member Status Menu.");
                        Console.WriteLine("");
                        cancellingMems = false;
                    }
                    else if (member2.Name == input)
                    {
                        Console.WriteLine("");
                        club.RemoveMemberFromClubByName(member2, input);
                        Console.WriteLine("This membership has been located and succesfully cancelled, and you'll be returned to the Modify Member Status Menu.");
                        Console.WriteLine("");
                        cancellingMems = false;
                    }
                    else
                    {
                        Console.WriteLine("I'm sorry, I could not locate a member by that name. Perhaps we experienced a typo. Would you like to try cancelling this membership again? (Y/N)");
                        string goAgainChoice = Console.ReadLine().Trim().ToLower();
                        if (goAgainChoice == "y" || goAgainChoice == "yes")
                        {
                            cancellingMems = true;
                        }
                        else if (goAgainChoice == "n" || goAgainChoice == "no")
                        {
                            cancellingMems = false;
                        }
                        else
                        {
                            Console.WriteLine("I'm sorry, I can only accept yes or no responses. Please try again.");
                            cancellingMems = true;
                        }
                    }
                }
                else
                {
                    Console.WriteLine("I'm sorry, I didn't recognize that decision. Please try again.");
                    cancellingMems = true;
                }
            }
        }
        static void Main(string[] args)
        {
            ListOfClubs listOfClubs = ListOfClubs.Instance;

            Club   testingClub   = new Club("Testing Club", "First Address");
            Member testingMember = new SingleClubMember(123, "Jon Doe", testingClub);

            testingClub.AddMemberToClub(testingMember);


            //------------------------------------------------------------------------------------------------
            //Beginning of Program Logic

            bool runProgram            = true;
            bool activeEmployeeSession = false;

            while (runProgram)
            {
                ClubController activeEmployee = new ClubController();
                activeEmployee.ClearCheckInMembers();
                GreetingsPrompt(activeEmployee);

                activeEmployeeSession = true;

                while (activeEmployeeSession)
                {
                    bool gettingMenuOption = true;
                    while (gettingMenuOption)
                    {
                        Console.WriteLine("This is the Main Menu of the Grand Circus Fitness Club Manager\nPlease input a menu option for services\n");

                        DirectionsPrompt(activeEmployee);

                        string input  = Console.ReadLine().Trim();
                        int    num    = 0;
                        bool   isANum = int.TryParse(input, out num);

                        if (isANum)
                        {
                            if (num > 0 && num <= 5)
                            {
                                switch (num)
                                {
                                case 1:
                                    //Option to check a member into a club
                                    activeEmployee.ActiveClub.MemberCheckIn(activeEmployee.ActiveClub);
                                    ListOfClubs.Instance.PrintAllClubsAndMembers();
                                    Console.Clear();
                                    break;

                                case 2:
                                    //Option to add a member to a club
                                    ModifyMemberStatus(activeEmployee);
                                    ListOfClubs.Instance.PrintAllClubsAndMembers();
                                    break;

                                case 3:
                                    //option to remove a member from a club
                                    SearchDataBase(activeEmployee);
                                    break;

                                case 4:
                                    activeEmployeeSession = LoginAnotherUser();
                                    gettingMenuOption     = false;
                                    Console.Clear();
                                    break;

                                case 5:
                                    //option to exit the program
                                    Console.WriteLine("Logging you out and closing the program...");
                                    Environment.Exit(0);
                                    break;
                                }
                            }
                            else if (num > 5)
                            {
                                Console.WriteLine("I'm sorry, that number is too high and I didn't recognize it. Please try again.");
                                gettingMenuOption = true;
                            }
                            else if (num <= 0)
                            {
                                Console.WriteLine("I'm sorry, that number is too low and I didn't recognize it. Please try again.");
                                Console.WriteLine("");
                                gettingMenuOption = true;
                            }
                        }
                        else
                        {
                            Console.WriteLine("I'm sorry, I didn't recognize a number. Please try again.");
                            Console.WriteLine("");
                            gettingMenuOption = true;
                        }
                    }
                }
            }
        }