Esempio n. 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);
        }
Esempio n. 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);
                }
            }
        }
Esempio n. 3
0
        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;
                }
            }
        }