Exemplo n.º 1
0
        public List <string> GetRegistrationNumbersByCarColor(string color)
        {
            if (ColorToRegistrationsMapping.ContainsKey(color.ToLower()) == false)
            {
                return(new List <string>());
            }

            var registrations = ColorToRegistrationsMapping[color.ToLower()];

            return(registrations);
        }
Exemplo n.º 2
0
        public void ParkCar(Car car, int slot)
        {
            RegistrationToParkingLotMapping.Add(car.RegistrationNumber, slot);
            Cars.Add(car.RegistrationNumber, car);

            if (ColorToRegistrationsMapping.ContainsKey(car.Color.ToLower()))
            {
                ColorToRegistrationsMapping[car.Color.ToLower()].Add(car.RegistrationNumber);
            }
            else
            {
                ColorToRegistrationsMapping.Add(car.Color.ToLower(), new List <string> {
                    car.RegistrationNumber
                });
            }
        }
Exemplo n.º 3
0
        public List <int> GetSlotNumbersOfCarByColor(string color)
        {
            var list = new List <int>();

            if (ColorToRegistrationsMapping.ContainsKey(color.ToLower()))
            {
                var registrations = ColorToRegistrationsMapping[color.ToLower()];
                foreach (var registration in registrations)
                {
                    if (RegistrationToParkingLotMapping.ContainsKey(registration))
                    {
                        list.Add(RegistrationToParkingLotMapping[registration]);
                    }
                }
            }

            return(list);
        }