Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
 public Vehicle Parse(IConsoleInputOutput console, string parameter, out int parkingPlaceId)
 {
     parkingPlaceId = 0;
     string[] propertyStrings = null;
     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], Parkplatznummer ");
         propertyStrings = this.preParse(console, 923, out parkingPlaceId);
     }
     else if (parameter == "m")
     {
         console.WriteLine("Geben Sie das Motorrad in folgendem Format ein:");
         console.WriteInfo("Hersteller, Modell, Kennzeichen, Jahr der Erstzulassung, Anschaffungspreis, Hubraum, Parkplatznummer");
         propertyStrings = this.preParse(console, 7, out parkingPlaceId);
     }
     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, Parkplatznummer ");
         propertyStrings = this.preParse(console, 8, out parkingPlaceId);
     }
     return(this.Parse(propertyStrings, parameter));
 }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        private void add(string parameter)
        {
            Vehicle vehicle;

            if (parameter == "g")
            {
                uint count  = 0;
                var  garage = garageParser.Parse(console, out count);
                if (count > 0)
                {
                    garageManager.AddGarage(garage, (int)count);
                    console.WriteInfo("Neues Parkhaus hinzugefügt und ausgewählt.");
                }
                else
                {
                    console.WriteError("Parkhaus konnte nicht hinzugefügt werden!");
                }
            }
            else if (parameter.Contains("+"))
            {
                parameter = parameter.Replace("+", "");
                int i = 0;
                vehicle = vehicleParser.Parse(console, parameter, out i);
                if (vehicle != null && vehicleManager.AddVehicle(vehicle, null))
                {
                    vehicleManager.AssignParkingPlace(vehicle, garageManager.GetParkingPlace(i));
                    console.WriteInfo("Fahrzeug hinzugefügt.");
                }
                else
                {
                    console.WriteError("Fahrzeug konnte nicht hinzugefügt werden!");
                }
            }
            else
            {
                vehicle = vehicleParser.Parse(console, parameter);
                if (vehicle != null && vehicleManager.AddVehicle(vehicle, null))
                {
                    vehicleManager.AssignParkingPlace(vehicle, garageManager.GetParkingPlace());
                    console.WriteInfo("Fahrzeug hinzugefügt.");
                }
                else
                {
                    console.WriteError("Fahrzeug konnte nicht hinzugefügt werden!");
                }
            }
        }