예제 #1
0
        private void SetEnergyType(string i_LicensePlateNumber)
        {
            bool  isSuccess    = false;
            float energyAmount = 0;

            while (!isSuccess)
            {
                try
                {
                    if (this.m_MyGarage.IsFuelBasedVehicle(i_LicensePlateNumber))
                    {
                        energyAmount = ChatBot.GetFuelCurStatus(i_LicensePlateNumber);
                    }
                    else
                    {
                        energyAmount = ChatBot.GetBatteryCurStatus(i_LicensePlateNumber);
                    }

                    this.m_MyGarage.SetEnergy(i_LicensePlateNumber, energyAmount);
                    isSuccess = true;
                }
                catch (ValueOutOfRangeException e)
                {
                    ChatBot.PrintValueOutOfRangeMessage(e.MaxValue, e.MinValue);
                }
            }
        }
예제 #2
0
        internal void InflateWheels()
        {
            string licensePlateNumber = GetLicensePlateNumber();
            int    numberOfWheels     = 0;

            float[] wheelsAirPressure;

            try
            {
                numberOfWheels    = this.m_MyGarage.GetNumOfWheelsInVehicle(licensePlateNumber);
                wheelsAirPressure = new float[numberOfWheels];
                for (int i = 0; i < wheelsAirPressure.Length; i++)
                {
                    wheelsAirPressure[i] = this.r_FillAirToMax;
                }

                this.m_MyGarage.FillAirInWheels(licensePlateNumber, wheelsAirPressure);
            }
            catch (VehicleNotInGarageException e)
            {
                ChatBot.PrintLicensePlateNotFoundMessage(licensePlateNumber);
            }
            catch (ValueOutOfRangeException e)
            {
                ChatBot.PrintValueOutOfRangeMessage(e.MaxValue, e.MinValue);
            }
        }
예제 #3
0
        private void SetWheels(string i_LicensePlateNumber)
        {
            string manufacturerName;
            float  curAirPressure = 0;
            bool   isSuccess      = false;

            ChatBot.GetWheelsManufacturer(i_LicensePlateNumber, out manufacturerName);
            while (!isSuccess)
            {
                try
                {
                    curAirPressure = ChatBot.GetCurAirPressure(i_LicensePlateNumber);
                    m_MyGarage.SetWheels(i_LicensePlateNumber, manufacturerName, curAirPressure);
                    isSuccess = true;
                }
                catch (ValueOutOfRangeException e)
                {
                    ChatBot.PrintValueOutOfRangeMessage(e.MaxValue, e.MinValue);
                }
            }
        }
예제 #4
0
        internal void FillEnergyInVehicle(bool isFuelRequired)
        {
            bool       chargedSuccessfully = false;
            bool       isFuelVehicle;
            float      amountToFill = 0;
            eFuelTypes fuelType;
            string     fuelTypeCode;
            string     licensePlateNumber = GetLicensePlateNumber();

            while (!chargedSuccessfully)
            {
                try
                {
                    isFuelVehicle = this.m_MyGarage.IsFuelBasedVehicle(licensePlateNumber);
                    if (isFuelVehicle)
                    {
                        if (isFuelRequired)
                        {
                            ChatBot.GetFuelingDetails(licensePlateNumber, out amountToFill, out fuelTypeCode);
                            eFuelTypes.TryParse(fuelTypeCode, out fuelType);
                            this.m_MyGarage.FillEnergy(licensePlateNumber, amountToFill, fuelType);
                        }
                        else
                        {
                            Console.WriteLine("Your vehicle based on Fuel, please select option #5.");
                        }
                    }
                    else
                    {
                        if (!isFuelRequired)
                        {
                            amountToFill = ChatBot.GetChargingDetails(licensePlateNumber);
                            this.m_MyGarage.FillEnergy(licensePlateNumber, amountToFill);
                        }
                        else
                        {
                            Console.WriteLine("Your vehicle based on Electric, please select option #6.");
                        }
                    }
                    Console.WriteLine("Please prees enter");
                    Console.ReadLine();
                    chargedSuccessfully = true;
                }
                catch (VehicleNotInGarageException e)
                {
                    ChatBot.PrintLicensePlateNotFoundMessage(licensePlateNumber);
                }
                catch (ValueOutOfRangeException e)
                {
                    ChatBot.PrintValueOutOfRangeMessage(e.MaxValue, e.MinValue);
                }
                catch (System.ArgumentException e)
                {
                    eFuelTypes.TryParse(e.Message, out fuelType);
                    ChatBot.PrintFuelTypeErrorMessage(fuelType);
                }
                catch (System.FormatException e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }