Ejemplo n.º 1
0
        private string[] preParse(IConsoleInputOutput console, int count, out int parkingPlaceId)
        {
            parkingPlaceId = 0;
            var str             = console.ReadLine();
            var propertyStrings = str.Split(',');

            if (propertyStrings.Count() == count)
            {
                int.TryParse(propertyStrings[count - 1], out parkingPlaceId);
            }
            return(propertyStrings);
        }
Ejemplo n.º 2
0
        public Vehicle Parse(IConsoleInputOutput console, string parameter)
        {
            string str;

            if (parameter == "c")
            {
                console.WriteLine("Geben Sie den PKW in folgendem Format ein:");
                console.WriteInfo("Hersteller, Modell, Kennzeichen, Jahr der Erstzulassung, Anschaffungspreis, Hubraum, Leistung, Schadstoffklasse [0-schadstoffarm, 1-normal, 2-Diesel] ");
                str = console.ReadLine();
                var propertyStrings = str.Split(',');
                if (propertyStrings.Count() == 8)
                {
                    return(Parse(propertyStrings, parameter));
                }
            }
            else if (parameter == "m")
            {
                console.WriteLine("Geben Sie das Motorrad in folgendem Format ein:");
                console.WriteInfo("Hersteller, Modell, Kennzeichen, Jahr der Erstzulassung, Anschaffungspreis, Hubraum");
                str = console.ReadLine();
                var propertyStrings = str.Split(',');
                if (propertyStrings.Count() == 6)
                {
                    return(Parse(propertyStrings, parameter));
                }
            }
            else if (parameter == "t")
            {
                console.WriteLine("Geben Sie den LKW in folgendem Format ein:");
                console.WriteInfo("Hersteller, Modell, Kennzeichen, Jahr der Erstzulassung, Anschaffungspreis, Anzahl der Achsen, Zuladung in t ");
                str = console.ReadLine();
                var propertyStrings = str.Split(',');
                if (propertyStrings.Count() == 7)
                {
                    return(Parse(propertyStrings, parameter));
                }
            }
            return(null);
        }
Ejemplo n.º 3
0
 private void park(string parameter)
 {
     if (string.IsNullOrEmpty(parameter))
     {
         foreach (var item in this.selectedVehicles)
         {
             console.WriteInfo("Bitte geben Sie die Parkplatznummer für \"" + item.Key.LicensePlate + "\" ein");
             var input          = console.ReadLine();
             int parkingPlaceId = 0;
             ParkingPlaceOutput parkingPlace = null;
             if (int.TryParse(input, out parkingPlaceId))
             {
                 parkingPlace = garageManager.GetParkingPlace(parkingPlaceId);
             }
             else
             {
                 parkingPlace = garageManager.GetParkingPlace();
             }
             if (item.Value != null)
             {
                 garageManager.ReleaseParkingPlace(item.Value);
             }
             vehicleManager.AssignParkingPlace(item.Key, parkingPlace);
             console.WriteInfo("Parkplatz erfolgreich zugewiesen.");
         }
     }
     else
     {
         int garageId = 0;
         var garages  = garageManager.GetAllGarages();
         ParkingPlaceOutput parkingPlace = null;
         int i = 0;
         if (int.TryParse(parameter, out garageId) && garageId > 0 && garageId <= garages.Count)
         {
             garageManager.SelectGarage(garages[garageId - 1]);
             foreach (var item in this.selectedVehicles)
             {
                 parkingPlace = garageManager.GetParkingPlace();
                 if (item.Value != null)
                 {
                     garageManager.ReleaseParkingPlace(item.Value);
                 }
                 vehicleManager.AssignParkingPlace(item.Key, parkingPlace);
                 i++;
             }
         }
         var word = i == 1 ? "Parkplatz" : "Parkplätze";
         console.WriteInfo($"{i} {word} erfolgreich zugewiesen.");
     }
     this.selectedVehicles = new Dictionary <Vehicle, ParkingPlaceOutput>();
 }
Ejemplo n.º 4
0
        public Garage Parse(IConsoleInputOutput console, out uint count)
        {
            console.WriteLine("Geben Sie das Parkhaus in folgendem Format ein:");
            console.WriteInfo("Ort, Plz, Straße & Nummer, Anzahl der Parkplätze");
            var str             = console.ReadLine();
            var propertyStrings = str.Split(',');

            count = (uint)propertyStrings.Count();
            if (count == 4)
            {
                uint.TryParse(propertyStrings[count - 1], out count);
                return(new Garage()
                {
                    City = propertyStrings[0],
                    Zip = propertyStrings[1],
                    Street = propertyStrings[2]
                });
            }
            return(null);
        }