Ejemplo n.º 1
0
 public Astronaut checkAstronaut(Astronaut astronaut)
 {
     foreach (Astronaut member in team)
     {
         if (member.getName() == astronaut.getName())
         {
             return member;
         }
     }
     return null;
 }
Ejemplo n.º 2
0
        public static void importPlan(XDocument doc, List<ActType> actTypeList, Mission mission)
        {
            foreach (XElement activity in doc.Descendants("Activity"))
            {
                int idType = Int32.Parse(activity.Parent.Parent.Attribute("ID").Value);
                ActType actType = actTypeList[idType - 1];

                int d = Int32.Parse(activity.Element("Day").Element("nDay").Value);
                Day day = new Day(d);
                Day checkDay = mission.checkDayList(day);
                if (checkDay == null)
                {
                    mission.addDay(day);
                }
                else
                {
                    day = checkDay;
                }

                int timeslotBegin = Int32.Parse(activity.Element("timeSlot").Element("start").Value);
                int timeslotEnd = Int32.Parse(activity.Element("timeSlot").Element("end").Value);
                TimeSlot timeSlot = new TimeSlot(timeslotBegin, timeslotEnd);

                string locName = activity.Element("Location").Element("Name").Value;
                int x = Int32.Parse(activity.Descendants("X").FirstOrDefault().Value);
                int y = Int32.Parse(activity.Descendants("Y").FirstOrDefault().Value);
                Location location = new Location(locName, new Position(x, y));
                Location checkLocation = mission.checkLocationList(location);
                if (checkLocation == null)
                {
                    mission.addLocation(location);
                }
                else
                {
                    location = checkLocation;
                }

                List<Astronaut> astrList = new List<Astronaut>();
                foreach (XElement astronaut in activity.Descendants("Astronaut"))
                {
                    string astroName = astronaut.Element("Name").Value;
                    Astronaut member = new Astronaut(astroName);
                    Astronaut checkMember = mission.checkAstronaut(member);
                    if (checkMember == null)
                    {
                        mission.addAstronaut(member);
                    }
                    else
                    {
                        member = checkMember;
                    }
                    astrList.Add(member);
                }

                string Desc = activity.Element("Desc").Value;

                Activity act = new Activity(actType, day, timeSlot, location, astrList, Desc);
                act.update();

            }
        }
Ejemplo n.º 3
0
 public void addAstronaut(Astronaut astronaut)
 {
     this.team.Add(astronaut);
 }