示例#1
0
        public void AddVehicleToGarage(string i_Owner, string i_Phone, VehicleInputData i_VehicleData)
        {
            VehicleCard newCard, foundCard;
            Vehicle     newVehicle;

            try
            {
                foundCard = FindCardByLicense(i_VehicleData.m_LicenseNumber);
            }
            catch (KeyNotFoundException)
            {
                foundCard = null;
            }

            if (foundCard == null)
            {
                newVehicle = VehicleCreator.CreateNewVehicle(i_VehicleData);
                newCard    = new VehicleCard(i_Owner, i_Phone, VehicleCard.eVehicleStatus.InService, newVehicle);
                m_Cards.Add(newCard);
            }
            else
            {
                foundCard.Status = VehicleCard.eVehicleStatus.InService;
                throw new VehicleAllreadyInGarageException(new Exception(), foundCard.Vehicle.LicenseNumber);
            }
        }
示例#2
0
        public void ChangeVehicleStatus(string i_LicenseNumber, VehicleCard.eVehicleStatus i_NewsStatus)
        {
            VehicleCard cardToChange = null;

            cardToChange = m_Cards.Find(vehicleToChange => vehicleToChange.Vehicle.LicenseNumber.Equals(i_LicenseNumber));
            if (cardToChange == null)
            {
                throw new KeyNotFoundException();           ///// license number? empty ctor?
            }
            cardToChange.Status = i_NewsStatus;
        }
示例#3
0
        public VehicleCard FindCardByLicense(string i_LicenseNumber)
        {
            VehicleCard o_FoundCard = null;

            o_FoundCard = m_Cards.Find(card => card.Vehicle.LicenseNumber.Equals(i_LicenseNumber));
            if (o_FoundCard == null)
            {
                throw new KeyNotFoundException();
            }

            return(o_FoundCard);
        }
示例#4
0
文件: Garage.cs 项目: TalKashi/CSharp
        public void AddNewVehicle(string i_VehicleType, string i_LicensePlateSrting, string i_VehicleModel, string i_OwnerName, string i_OwnerPhone, float i_EnergyLeft, string i_WheelManufacturer, float i_WheelCurrentAirPressure, string[] i_Parameters)
        {
            Vehicle newVehicle = VehicleInfo.CreateVehicle(i_VehicleType, i_LicensePlateSrting, i_VehicleModel, i_EnergyLeft, i_WheelManufacturer, i_WheelCurrentAirPressure, i_Parameters);

            m_VehicleCards[i_LicensePlateSrting] = new VehicleCard(i_OwnerName, i_OwnerPhone, newVehicle);
        }