Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
 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.");
     }
 }