Exemple #1
0
 /// <summary>
 /// Add a boat menu
 /// </summary>
 /// <param name="a_member">model.Member, the member who owns the new boat</param>
 private void AddBoat(model.Member a_member)
 {
     m_console.AddBoat(a_member);
     for (int i = 0; i < (int)model.Boat.Type.Count; i += 1)
     {
         string message = string.Format("{0}: {1}", i, (model.Boat.Type)i);
         m_console.WriteMessage(message);
     }
     int type;
     while (true)
     {
         m_console.WriteMessage("Type: ");
         bool isNumeric = int.TryParse(m_console.ReadResponse(), out type);
         if (isNumeric && type >= 0 && type < (int)model.Boat.Type.Count)
         {
             break;
         }
         m_console.WriteMessage("Invalid type, type must be a number choosen from the list above");
     }
     double length;
     while (true)
     {
         m_console.WriteMessage("Length: ");
         bool isDouble = double.TryParse(m_console.ReadResponse(), out length);
         if (isDouble && length > 0)
         {
             break;
         }
         m_console.WriteMessage("Invalid length. Length must be of the format XX or XX,XX");
     }
     a_member.GetBoatList().AddBoat((model.Boat.Type)type, length);
     m_console.SetCurrentMenu(view.Console.CurrentMenu.Member);
     GoToCurrentMenu(a_member);
 }
Exemple #2
0
 /// <summary>
 /// Displays a boat to the user
 /// </summary>
 /// <param name="a_member">model.Member. The member that ownes the boat</param>
 /// <param name="a_boatID">int. The ID of that boat to be displayed</param>
 public void DisplayBoat(model.Member a_member, int a_boatID)
 {
     foreach (model.Boat boat in a_member.GetBoatList().GetBoats()){
         if(a_boatID == boat.GetBoatID()) {
             System.Console.WriteLine("BoatID: {0}", a_boatID);
             System.Console.WriteLine("Type: {0}", boat.GetBoatType());
             System.Console.WriteLine("Length: {0}", boat.GetLength());
             break;
         }
     }
 }
Exemple #3
0
        /// <summary>
        /// Display a member to the user
        /// </summary>
        /// <param name="a_member">model.Member. The member to be displayed</param>
        /// <param name="showPNumber">bool. True if the Personal Number should be displayed, false otherwise</param>
        /// <param name="showBoats">bool. True if the boats the user owns should be displayed, false if only the number of boats owned should be displayed</param>
        public void DisplayMember(model.Member a_member, bool showPNumber, bool showBoats)
        {
            System.Console.WriteLine("---");
            System.Console.WriteLine("MemberID: {0}", a_member.GetMemberID());
            System.Console.WriteLine("Name: {0}", a_member.GetName());

            if (showPNumber)
            {
                System.Console.WriteLine("Personal Number: {0}", a_member.GetPNumber());
            }

            List<model.Boat> boats = a_member.GetBoatList().GetBoats();

            if (boats.Count > 0)
            {
                if (showBoats)
                {
                    System.Console.WriteLine("Boats:");

                    foreach (model.Boat boat in boats)
                    {
                        DisplayBoat(boat);
                    }
                }
                else
                {
                    System.Console.WriteLine("Boats: {0}", boats.Count);
                }
            }
        }
Exemple #4
0
 /// <summary>
 /// Read a response from the user, from the specific member menu and change the users menu position accordingly
 /// </summary>
 /// <param name="a_member"></param>
 private void MemberResponse(model.Member a_member)
 {
     int response = m_console.GetMemberResponse();
     if (response == -1)
     {
         m_memberList.RemoveMember(a_member);
         GoToCurrentMenu();
         return;
     }
     else if (response > 0)
     {
         foreach (model.Boat boat in a_member.GetBoatList().GetBoats())
         {
             if (boat.GetBoatID() == response)
             {
                 GoToCurrentMenu(a_member, response);
                 return;
             }
         }
         m_console.SetCurrentMenu(view.Console.CurrentMenu.Member);
     }
     GoToCurrentMenu(a_member);
 }
Exemple #5
0
 /// <summary>
 /// Edit boat menu
 /// </summary>
 /// <param name="a_member">model.Member, the member that owns the boat</param>
 /// <param name="a_boatID">int, the boatID of the boat</param>
 private void EditBoat(model.Member a_member, int a_boatID)
 {
     bool boatExists = false;
     foreach (model.Boat boat in a_member.GetBoatList().GetBoats())
     {
         if (boat.GetBoatID() == a_boatID)
         {
             boatExists = true;
             break;
         }
     }
     if (boatExists)
     {
         m_console.EditBoat(a_member, a_boatID);
         for (int i = 0; i < (int)model.Boat.Type.Count; i += 1)
         {
             string message = string.Format("{0}: {1}", i, (model.Boat.Type)i);
             m_console.WriteMessage(message);
         }
         int type;
         while (true)
         {
             m_console.WriteMessage("New type: ");
             bool isNumeric = int.TryParse(m_console.ReadResponse(), out type);
             if (isNumeric && type >= 0 && type < (int)model.Boat.Type.Count)
             {
                 break;
             }
             m_console.WriteMessage("Invalid type, type must be a number choosen from the list above");
         }
         double length;
         while (true)
         {
             m_console.WriteMessage("New length: ");
             bool isDouble = double.TryParse(m_console.ReadResponse(), out length);
             if (isDouble && length > 0)
             {
                 break;
             }
             m_console.WriteMessage("Invalid length. Length must be of the format XX or XX,XX");
         }
         a_member.GetBoatList().ChangeBoatInfo(a_boatID, (model.Boat.Type)type, length);
     }
     m_console.SetCurrentMenu(view.Console.CurrentMenu.Member);
     GoToCurrentMenu(a_member);
 }
Exemple #6
0
 /// <summary>
 /// Read a response from the user, from the specific boat menu and change the users menu position accordingly
 /// </summary>
 /// <param name="a_member">model.Member, the member that owns the boat</param>
 /// <param name="a_boatID">int, the boatID of the boat</param>
 private void BoatResponse(model.Member a_member, int a_boatID)
 {
     int response = m_console.GetBoatResponse();
     if (response == -1)
     {
         a_member.GetBoatList().RemoveBoat(a_boatID);
         GoToCurrentMenu(a_member);
         return;
     }
     GoToCurrentMenu(a_member, a_boatID);
 }