Exemplo n.º 1
0
 internal bool LoadGarageFromFile()
 {
     using (StreamReader sr = File.OpenText("garage.txt"))
     {
         var capacity     = ReadSecondPartOfLineAsInt(sr);
         var vehicleCount = ReadSecondPartOfLineAsInt(sr);
         for (int i = 0; i < vehicleCount; i++)
         {
             var typeString = sr.ReadLine();
             var properties = vehicleTypes[typeString].GetProperties();
             if (properties.Length == 10)
             {
                 var dTO = new AircraftDTO();
                 populateDTO(dTO, properties);
             }
             foreach (var property in properties)
             {
                 if (property.PropertyType.IsAssignableFrom(UI.typeInteger))
                 {
                     ReadSecondPartOfLineAsInt(sr);
                 }
             }
         }
         return(true);
     }
 }
Exemplo n.º 2
0
 internal static bool CreateAircraft(AircraftDTO input, out Aircraft vehicle)
 {
     vehicle = null;
     try
     {
         vehicle = new Aircraft(input.RegistrationNumber, input.ColorOrLivery, input.NumberOfLandingGearAssemblies,
                                input.EmptyMass, input.Manufacturer, input.Model, input.TypeDesignator, input.AircraftType, input.EngineType, input.EngineCount);
         return(true);
     } catch (NullReferenceException e)
     {
         Console.Error.Write(e.Message);
         return(false);
     }
 }
Exemplo n.º 3
0
        private void ParkAircraft()
        {
            AircraftDTO aircraftDTO = new AircraftDTO();

            PopulateAircraftDTO(aircraftDTO);
            Aircraft aircraft;

            if (VehicleCreator.CreateAircraft(aircraftDTO, out aircraft))
            {
                if (handler.ParkVehicle(aircraft))
                {
                    AnnounceParkingSuccess(aircraft.RegistrationNumber);
                }
            }
        }
Exemplo n.º 4
0
 private void PopulateAircraftDTO(AircraftDTO aircraftDTO)
 {
     Console.Write("Registration number: ");
     aircraftDTO.RegistrationNumber = Console.ReadLine().ToLower();
     Console.Write("Color or livery: ");
     aircraftDTO.ColorOrLivery = Console.ReadLine().ToLower();
     Console.Write("Empty mass in kilograms: ");
     aircraftDTO.EmptyMass = GetInteger(0, int.MaxValue);
     Console.Write("Number of landing gear assemblies: ");
     aircraftDTO.NumberOfLandingGearAssemblies = GetInteger(0, 20);
     Console.Write("Manufacturer: ");
     aircraftDTO.Manufacturer = Console.ReadLine().ToLower();
     Console.Write("Model: ");
     aircraftDTO.Model = Console.ReadLine().ToLower();
     Console.Write("Type designator: ");
     aircraftDTO.TypeDesignator = Console.ReadLine().ToUpper();
     Console.WriteLine("Type description: " + GetTypeString(aircraftTypes));
     aircraftDTO.AircraftType = (AircraftType)GetInteger(0, 5);
     Console.WriteLine("Engine type: " + GetTypeString(aircraftEngineTypes));
     aircraftDTO.EngineType = (AircraftEngineType)GetInteger(0, 5);
     Console.Write("Engine count: ");
     aircraftDTO.EngineCount = GetInteger(0, 16);
 }
Exemplo n.º 5
0
 private void populateDTO(AircraftDTO dTO, PropertyInfo[] properties)
 {
 }