예제 #1
0
파일: Garage.cs 프로젝트: hihilla/csharp3
        public void ChangeVehicleState(string i_VehicleLicence, Vehicle.eVehicleState i_VehicleState)
        {
            Vehicle vehicle;

            if (m_VehiclesInGarage.TryGetValue(i_VehicleLicence, out vehicle))
            {
                vehicle.VehicleState = i_VehicleState;
            }
            else
            {
                throw new ArgumentException(string.Format("Vehicle with licence number {0} does not exsist", i_VehicleLicence));
            }
        }
        public string DisplayVehiclesLicenses(string i_VehicleState)
        {
            if (m_GarageVehicles.Count == 0)
            {
                return("There are no existing vehicles");
            }
            else
            {
                StringBuilder         vehicleLicenses = new StringBuilder();
                Vehicle.eVehicleState vehicleState    = Vehicle.GetVehicleState(i_VehicleState);

                foreach (Vehicle vehicle in m_GarageVehicles)
                {
                    if (vehicle.VehicleStatus == vehicleState)
                    {
                        vehicleLicenses.Append(vehicle.LicenseNumber + "\n");
                    }
                }

                return(vehicleLicenses.ToString());
            }
        }