public void addBoat(Boat boat)
 {
     if (allBoats.Contains(boat))
     {
         throw new Exception("Boat already exists.");
     }
     else { allBoats.Add(boat); }
 }
 public void deleteBoat(Boat boat)
 {
     if (allBoats.Contains(boat))
     {
         allBoats.Remove(boat);
     }
     else
         throw new Exception("Boat does not exist.");
 }
Exemple #3
0
        /// <summary>
        /// Adds a new member and all his boats to the xml file (like a saving process)
        /// </summary>
        public override void add()
        {
            XmlDocument doc = new XmlDocument();
            doc.Load("Storage.xml");
            XmlElement id = doc.CreateElement(myGuid.ToString());
            id.SetAttribute(last_Name, first_Name, personal_Number.ToString());

            XmlElement xBoats = doc.CreateElement("boats");
            id.AppendChild(xBoats);

            foreach (Boat b in boats){
                Boat newBoat = new Boat();
                XmlElement xNewBoat = doc.CreateElement(newBoat.myGuid.ToString());
                xNewBoat.SetAttribute(newBoat.GetType().ToString(), newBoat.Length.ToString());
                xBoats.AppendChild(xNewBoat);
            }
            doc.AppendChild(id);
        }
 public void updateBoat(Member member, Boat boat)
 {
     if (allMembers.Contains(member))
     {
         if (allBoats.Contains(boat))
         {
             Boat newBoat = new Boat();
             newBoat.SetType(boat.GetType());
             newBoat.Length = boat.Length;
             boat.delete();
             newBoat.add();
         }
         else
         {
             throw new Exception ("Boat does not exist.");
         }
     }
     else
     {
         throw new Exception("Member does not exist.");
     }
 }