Beispiel #1
0
 public void UpdateBoat(Boat a_old, Boat a_new)
 {
     a_old.Set(a_new);
 }
Beispiel #2
0
 public void DeleteBoat(Boat a_boat)
 {
     m_boats.Remove(a_boat);
 }
Beispiel #3
0
 public void Set(Boat a_boat)
 {
     m_type = a_boat.m_type;
     m_length = a_boat.m_length;
 }
Beispiel #4
0
 public void AddBoat(Boat a_boat)
 {
     m_boats.Add(a_boat);
 }
Beispiel #5
0
        public void LoadFromFile()
        {
            string loadLine;
            MemberReadStatus status = MemberReadStatus.Indefinite;

            using (StreamReader loader = new StreamReader(m_location))
            {
                while ((loadLine = loader.ReadLine()) != null)
                {
                    if (loadLine == "")
                    {
                        continue;
                    }

                    if (loadLine == "[Member]")
                    {
                        status = MemberReadStatus.Member;
                    }

                    else if (loadLine == "[Boat]")
                    {
                        status = MemberReadStatus.Boat;
                    }

                    else
                    {
                        if (status == MemberReadStatus.Member)
                        {
                            string[] splitMember = loadLine.Split(';');
                            m_members.Add(new Member(splitMember[0], splitMember[1], splitMember[2], int.Parse(splitMember[3])));

                        }

                        else if (status == MemberReadStatus.Boat)
                        {
                            //    if (splitBoat.Length != 3)
                            //    {
                            //        throw new Exception("Det är fel antal ord på raden");
                            //    }
                            string[] splitBoat = loadLine.Split(';');
                            foreach (Member m in m_members)
                            {
                                if(m.GetMemberId() == int.Parse(splitBoat[0]))
                                {
                                    model.Boat.BoatType typeOfBoat;
                                    Enum.TryParse(splitBoat[1], out typeOfBoat);
                                    Boat b = new Boat(typeOfBoat, double.Parse(splitBoat[2]));
                                    m.AddBoat(b);
                                }
                            }

                        }

                    }
                }
            }
            CheckMemberId();
        }