コード例 #1
0
        private void CargeBattaryEngine()
        {
            string licensePlate;
            bool   isValidInput   = true;
            float  amountOfEnergy = 0;

            do
            {
                isValidInput = true;
                m_InputUI.GetVehicleLicenseNumberFromUser(m_Garage, out licensePlate);
                ElectricSource battaryEngine = m_Garage.AllCarsInGarage[licensePlate].Vehicle.EnergySource as ElectricSource;
                if (battaryEngine != null)
                {
                    try
                    {
                        amountOfEnergy = m_InputUI.GetDataFloatFromUser("minutue of electic engine");
                        battaryEngine.AddHoursToBatery(amountOfEnergy);
                    }
                    catch (ValueOutOfRangeException)
                    {
                        m_OutputUI.PrintStringToScreen(string.Format("Out of range, the range should be between 0 to {0}", battaryEngine.MaxEnergy));
                        isValidInput = false;
                    }
                }
                else
                {
                    Console.WriteLine("Not electric source!");
                }
            }while (!isValidInput);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: huruiyi/DotNet-Draft
 public void Charging(ElectricSource oElectricsource)
 {
 }