Ejemplo n.º 1
0
 public void DeleteMember(Member member)
 {
     if (!m_members.Contains(member))
     {
         throw new ArgumentException("That member doesn't exist");
     }
     m_members.Remove(member);
 }
Ejemplo n.º 2
0
 // Try to add the member to the register but validates the id and the ssn/pn, before that happens
 public void AddMember(Member memberToRegister)
 {
     foreach (Member m in _members)
     {
         if (m.PersonalNumber == memberToRegister.PersonalNumber)
         {
             throw new ArgumentException("A member with specified personal number already exists");
         }
     }
     _members.Add(memberToRegister);
 }
Ejemplo n.º 3
0
        private void Load()
        {
            try
            {
                // Creates a list that can contain references to member object.
                List<Member> members = new List<Member>();

                Member member = null;
                Boat boat = null;

                using (StreamReader reader = new StreamReader(_path))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        if (line != "")
                        {
                            // Divide the line into parts.
                            string[] values = line.Split(';');

                            // If there is a section for new member. (status,memberid,name,personalnumber)
                            if (values[0] == _sectionMember)
                            {
                                int memberId = int.Parse(values[1]);
                                string name = values[2];
                                string personalNumber = values[3];
                                member = new Member(memberId, name, personalNumber);
                                members.Add(member);
                            }
                            // If there is a section for boat. (status,type,length,registrationdate)
                            else if (values[0] == _sectionBoat)
                            {
                                Boat.BoatType type;
                                Enum.TryParse(values[1], out type);
                                double length = double.Parse(values[2]);
                                DateTime registrationDate = DateTime.Parse(values[3]);
                                boat = new Boat(type, length, registrationDate);
                                member.AddBoat(boat);
                            }
                            else
                            {
                                throw new FileLoadException();
                            }
                        }
                    }
                }
                _members = members.OrderBy(r => r.MemberId).ToList();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 4
0
 internal Member NewMemberInput(int uniqueID)
 {
     System.Console.Clear();
     string name;
     string personalNumber;
     Console.Write("Enter Name:");
     name=Console.ReadLine();
     Console.WriteLine("Enter Personal number:");
     personalNumber = Console.ReadLine();
     Member member = new Member(name, personalNumber, uniqueID+1);
     return member;
 }
Ejemplo n.º 5
0
 public Member UpdateMember()
 {
     int id = 0;
     string name="";
     string personalNumber="";
     try
     {
         Console.WriteLine("Enter ID of member you want to Update:");
         id = Int32.Parse(Console.ReadLine());
         Console.WriteLine("Enter name of member you want to Update:");
         name = Console.ReadLine();
         Console.WriteLine("Enter personal number of member you want to Update:");
         personalNumber=Console.ReadLine();
     }
     catch (FormatException e)
     {
         Console.WriteLine(e.Message);
     }
     Member member = new Member("","",0);
     member.UniqueID = id;
     member.Name = name;
     member.PersonalNumber = personalNumber;
     return member;
 }
Ejemplo n.º 6
0
 // Delete the specified member to delete from the memberlist
 public void DeleteMember(Member memberToDelete)
 {
     _members.Remove(memberToDelete);
 }