Пример #1
0
 public Pilot(PilotProfile profile, DateTime educationTime, PilotRating rating)
 {
     Profile = profile;
     EducationTime = educationTime;
     Rating = rating;
     Aircrafts = new List<string>();
 }
Пример #2
0
 public PilotStudent(
     PilotProfile profile,
     DateTime startDate,
     Instructor instructor,
     PilotRating rating,
     string airlinerfamily)
 {
     Rating = rating;
     Profile = profile;
     StartDate = startDate;
     EndDate = StartDate.AddDays(Rating.TrainingDays);
     Instructor = instructor;
     AirlinerFamily = airlinerfamily;
 }
Пример #3
0
 public Instructor(PilotProfile profile, PilotRating rating)
 {
     Profile = profile;
     Rating = rating;
     Students = new List<PilotStudent>();
 }
        private void btnHire_Click(object sender, RoutedEventArgs e)
        {
            IEnumerable<TrainingAircraftType> aircraftsTypesFree = FlightSchool.Aircrafts.Select(a => a.Type);

            Dictionary<TrainingAircraftType, int> types =
                FlightSchool.Aircrafts.GroupBy(a => a.Type)
                    .Select(group => new { Type = group.Key, Count = group.Sum(g => g.Type.MaxNumberOfStudents) })
                    .ToDictionary(g => g.Type, g => g.Count);
            ;

            foreach (PilotStudent student in FlightSchool.Students)
            {
                TrainingAircraftType firstAircraft =
                    student.Rating.Aircrafts.OrderBy(a => a.TypeLevel)
                        .FirstOrDefault(a => types.ContainsKey(a) && types[a] > 0);

                if (firstAircraft != null && types.ContainsKey(firstAircraft))
                {
                    types[firstAircraft]--;
                }
            }

            var possibleRatings = new List<PilotRating>();

            foreach (PilotRating rating in PilotRatings.GetRatings())
            {
                if (rating.Aircrafts.Exists(a => types.ContainsKey(a) && types[a] > 0))
                {
                    possibleRatings.Add(rating);
                }
            }

            WPFMessageBoxResult result = WPFMessageBox.Show(
                Translator.GetInstance().GetString("MessageBox", "2811"),
                string.Format(Translator.GetInstance().GetString("MessageBox", "2811", "message")),
                WPFMessageBoxButtons.YesNo);

            if (result == WPFMessageBoxResult.Yes)
            {
                List<Town> towns = Towns.GetTowns(FlightSchool.FlightSchool.Airport.Profile.Country);

                Town town = towns[rnd.Next(towns.Count)];
                DateTime birthdate = MathHelpers.GetRandomDate(
                    GameObject.GetInstance().GameTime.AddYears(-35),
                    GameObject.GetInstance().GameTime.AddYears(-23));
                var profile = new PilotProfile(
                    Names.GetInstance().GetRandomFirstName(town.Country),
                    Names.GetInstance().GetRandomLastName(town.Country),
                    birthdate,
                    town);

                var instructor = (Instructor)cbInstructor.SelectedItem;
                string airlinerFamily = cbTrainAircraft.SelectedItem.ToString();

                var student = new PilotStudent(
                    profile,
                    GameObject.GetInstance().GameTime,
                    instructor,
                    GeneralHelpers.GetPilotStudentRating(instructor, possibleRatings),
                    airlinerFamily);

                TrainingAircraft aircraft = getStudentAircraft(student);

                student.Aircraft = aircraft;

                FlightSchool.addStudent(student);
                instructor.AddStudent(student);

                setHireStudentsStatus();

                double studentPrice = GeneralHelpers.GetInflationPrice(PilotStudent.StudentCost);

                AirlineHelpers.AddAirlineInvoice(
                    GameObject.GetInstance().HumanAirline,
                    GameObject.GetInstance().GameTime,
                    Invoice.InvoiceType.AirlineExpenses,
                    -studentPrice);
            }
        }