Esempio n. 1
0
        /// <summary>
        /// Renders the verbose member list view.
        /// </summary>
        public void verboseListView(MemberList memberList)
        {
            Console.WriteLine("\n-----VERBOSE MEMBER LIST-----\n");
            Console.WriteLine("___________________");

            foreach (Member member in memberList.getMembers())
            {
                int    i = 1;
                string memberInfoString = $"\nName: {member.Name}\nPersonal number: {member.Number}\nId: {member.Id}\n";
                Console.WriteLine(memberInfoString);

                //Writes out each boats information
                foreach (Boat boat in member.getBoats())
                {
                    string boatInfoString = $"Boat #{i}\nType: {boat.Type}\nLength: {boat.Length}\n";
                    i++;
                    Console.WriteLine(boatInfoString);
                }
                Console.WriteLine("___________________");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Updates a members information.
        /// </summary>
        public void updateMember(View view, MemberList memberList)
        {
            List <String> memberIdandActionInput = view.updateMemberView();
            int           memberId = Int32.Parse(memberIdandActionInput[0]);
            string        action   = memberIdandActionInput[1];
            Member        member   = memberList.getMember(memberId);

            if (checkID(memberList, memberId) == false)
            {
                view.errorMessage(1);
                return;
            }

            //Update Member info
            if (action == "1")
            {
                List <String> nameAndNumberinput = view.updateMemberInfoView();
                member.updateMemberInfo(nameAndNumberinput[0], nameAndNumberinput[1]);
                view.successMessage(3);
                return;
            }

            //Add boat
            if (action == "2")
            {
                List <String> boatTypeAndLengthInput = view.addBoatView();

                //Error handling
                if (boatTypeAndLengthInput[0] != "Sailboat" && boatTypeAndLengthInput[0] != "Motorsailer" && boatTypeAndLengthInput[0] != "Kayak" && boatTypeAndLengthInput[0] != "Canoe" && boatTypeAndLengthInput[0] != "Other")
                {
                    view.errorMessage(3);
                    return;
                }

                if (checkBoat(member, boatTypeAndLengthInput[0]) == true)
                {
                    view.errorMessage(4);
                    return;
                }

                member.addBoat(boatTypeAndLengthInput[0], Int32.Parse(boatTypeAndLengthInput[1]));
                view.successMessage(4);
                return;
            }

            //Delete boat
            if (action == "3")
            {
                String boatTypeInput = view.deleteBoatView();

                //Error handling
                if (checkBoat(member, boatTypeInput) == false)
                {
                    view.errorMessage(5);
                    return;
                }

                member.deleteBoat(boatTypeInput);
                view.successMessage(5);
                return;
            }
            //Update boat
            if (action == "4")
            {
                List <String> boatTypeAndLengthInput = view.updateBoatView();

                //Error handling
                if (checkBoat(member, boatTypeAndLengthInput[0]) == false)
                {
                    view.errorMessage(5);
                    return;
                }

                member.updateBoat(boatTypeAndLengthInput[0], Int32.Parse(boatTypeAndLengthInput[1]));
                view.successMessage(6);

                //Error handling
            }
            else if (action != "1" && action != "2" && action != "3" && action != "4")
            {
                view.errorMessage(2);
                return;
            }
            //Saves member list to file.
            memberList.writeMemberListToFile();
        }