Esempio n. 1
0
        public void DisplayBoatMenu(Member member, Boat boat)
        {
            Console.Clear();
            Console.WriteLine("╔════════════════════════════════════════════════════════════════╗");
            Console.WriteLine("║ █▓▒░              BOAT MEMBERSHIP - BOAT                  ░▒▓█ ║");
            Console.WriteLine("╠════════════════════════════════════════════════════════════════╣");
            Console.WriteLine("║ Boat type:       {0,15}                               ║", boat.BoatType.ToString());
            Console.WriteLine("║ Boat length:     {0,15} meters                        ║", boat.Length);
            Console.WriteLine("╠════════════════════════════════════════════════════════════════╣");
            Console.WriteLine("║ 1: Edit boat                                                   ║");
            Console.WriteLine("║ 2: Remove boat                                                 ║");
            Console.WriteLine("╠════════════════════════════════════════════════════════════════╣");
            Console.WriteLine("║ 0: Back to member menu                                         ║");
            Console.WriteLine("╚════════════════════════════════════════════════════════════════╝");
            Console.WriteLine();

        }
 private void HandleEditBoat(Member member, Boat boat)
 {
     boatView.DisplayBoatTypeMenu();
     var inputValue = memberView.GetIntegerInput(5, "Current type: " + boat.BoatType.ToString() + ", new boat type", 0);
     if (inputValue == 0)
     {
         return;
     }
     var boatType = (BoatType)(inputValue - 1);
     var boatLength = memberView.GetDoubleInput(100.0, "Current length: " + boat.Length + ", new boat length (meters)", 1.0);
     boatManager.Update(boat, boatLength, boatType);
 }
 private void HandleRemoveBoat(Member member, Boat boat)
 {
     var confirmRemove = memberView.GetConfirm("Are you sure you want to remove this boat?");
     if (confirmRemove)
     {
         boatManager.RemoveBoat(boat);
     }
 }
 private void HandleAddBoat(Member member)
 {
     boatView.DisplayBoatTypeMenu();
     var inputValue = boatView.GetIntegerInput(5, "Pick boat type", 1);
     var boatType = (BoatType)(inputValue - 1);
     var boatLength = boatView.GetDoubleInput(100.0, "Specify boat length as meters (min 1, max 100 m)", 1.0);
     var boatIndex = boatManager.AddBoat(boatLength, boatType);
 }
 private void HandleBoat(Member member, int boatIndex)
 {
     int menuInput;
     do
     {
         var hasBoat = boatManager.HasBoat(boatIndex);
 
         if (hasBoat)
         {
             var boat = boatManager.GetBoat(boatIndex);
             boatView.DisplayBoatMenu(member, boat);
             menuInput = memberView.GetIntegerInput(2, "Make your selection");
             switch (menuInput)
             {
                 case 1:
                     HandleEditBoat(member, boat);
                     break;
                 case 2:
                     HandleRemoveBoat(member, boat);
                     menuInput = 0;
                     break;
             }
         }
         else
         {
             menuInput = 0;      //In case we end up in this menu after removing a boat
         }
     } while (menuInput != 0);    
 }
 private void HandleBoats(Member member)
 {
     int menuInput = 0;
     do
     {
         var boats = boatManager.GetBoatList();
         if (boats.Count == 0)
         {
             memberView.DisplayNoBoats();
             ContinueOnKeyPressed();
             break;
         }
         else if (boats.Count == 1)
         {
             HandleBoat(member, 0);
             break;
         }
         else
         {
             boatView.DisplayBoatsMenu(boats);
             menuInput = memberView.GetIntegerInput(boats.Count, "Make your selection");
             if (menuInput != 0)
             {
                 HandleBoat(member, menuInput - 1);
             }
         }
     } while (menuInput != 0);
 }
 private void HandleEditMember(Member member)
 {
     var newName = member.Name;
     var newSocialSecurityNumber = member.SocialSecurityNumber;
     //pressing <ENTER> keeps previous name.
     var name = memberView.GetStringInput(100, "Current name: " + member.Name + ", new name", 0);
     if (!string.IsNullOrWhiteSpace(name))
     {
         newName = name;
     }
     //pressing <ENTER> keeps previous social security number.
     var ssn = memberView.GetStringInput(11, "Enter social security number (YYMMDD-XXXX or XXX-XX-XXXX)", 0, @"^(?:\s*|\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[1-2]\d|3[0-1])\-?\d{4}|\d{3}\-?\d{2}\-?\d{4})$");
     if (!string.IsNullOrWhiteSpace(ssn))
     {
         newSocialSecurityNumber = ssn;
     }
     memberRegister.UpdateMember(member, newName, newSocialSecurityNumber);
 }
 private void HandleRemoveMember(Member member)
 {
     var confirmRemove = memberView.GetConfirm("Are you sure you want to remove this member?");
     if (confirmRemove)
     {
         memberRegister.DeleteMember(member);
     }
 }
 private void HandleMember(Member member)
 {
     int menuInput;
     do
     {
         if (memberRegister.IsMember(member.Id))
         {
             var boats = boatManager.GetBoatList();
             memberView.DisplayMember(member, boats);
             if (memberRegister.IsLoggedIn)
             {
                 menuInput = memberView.GetIntegerInput(4, "Make your selection");
             }
             else
             {
                 menuInput = memberView.GetIntegerInput(0, "Make your selection");
             }
             switch (menuInput)
             {
                 case 1:
                     HandleAddBoat(member);
                     member = memberRegister.GetMemberInfo(member.Id);
                     break;
                 case 2:
                     HandleBoats(member);
                     break;
                 case 3:
                     HandleEditMember(member);
                     member = memberRegister.GetMemberInfo(member.Id);
                     break;
                 case 4:
                     HandleRemoveMember(member);
                     break;
             }
         }
         else
         {
             menuInput = 0; //Leave this menu if user doesn't exist
         }
     } while (menuInput != 0);
 }
Esempio n. 10
0
 public Member AddMember(string name, string socialSecurityNumber)
 {
     var member = new Member(name, socialSecurityNumber, getNewMemberId());
     Members.Add(member);
     return member;
 }
Esempio n. 11
0
 public void UpdateMember(Member memberInfo, string name, string ssn)
 {
     var member = GetMember(memberInfo.Id);
     member.Update(name, ssn);
 }
Esempio n. 12
0
 public BoatManager GetBoatManager(Member memberInfo)
 {
     var member = GetMember(memberInfo.Id);
     return member.BoatManager;
 }
Esempio n. 13
0
 public void DeleteMember(Member memberInfo)
 {
     var member = GetMember(memberInfo.Id);
     Members.Remove(member);
 }
Esempio n. 14
0
        public void DisplayMember(Member member, ReadOnlyCollection<Boat> boats)
        {
            Console.Clear();
            Console.WriteLine("╔════════════════════════════════════════════════════════════════╗");
            Console.WriteLine("║ █▓▒░             BOAT MEMBERSHIP - MEMBER                 ░▒▓█ ║");
            Console.WriteLine("╠════════════════════════════════════════════════════════════════╣");
            Console.WriteLine("║ Name:       {0,17}                                  ║", member.Name);
            Console.WriteLine("║ Member id:  {0,17}                                  ║", member.Id);
            Console.WriteLine("║ Member ssn: {0,17}                                  ║", member.SocialSecurityNumber);
            Console.WriteLine("║ No. of boats: {0,15}                                  ║", boats.Count);

            if (boats.Count > 0)
            {
                Console.WriteLine("╠════════════════════════════════════════════════════════════════╣");
                DisplayBoatList(boats);
            }
            Console.WriteLine("╠════════════════════════════════════════════════════════════════╣");
            if (memberRegister.IsLoggedIn)
            {
                Console.WriteLine("║ 1: Add boat                                                    ║");
                Console.WriteLine("║ 2: Manage boats                                                ║");
                Console.WriteLine("║ 3: Edit member                                                 ║");
                Console.WriteLine("║ 4: Remove member                                               ║");
                Console.WriteLine("╠════════════════════════════════════════════════════════════════╣");
            }
            Console.WriteLine("║ 0: Back to main menu                                           ║");
            Console.WriteLine("╚════════════════════════════════════════════════════════════════╝");
            Console.WriteLine();
        }