示例#1
0
        private EnergySource getEnergySourceFromUser(bool i_ForTruck)
        {
            DataInputScreen dataInputScreen  = r_Screens[eUIScreens.DataInput] as DataInputScreen;
            eEnergySource   energySourceType = eEnergySource.Fuel;
            EnergySource    energySource     = null;

            if (!i_ForTruck)
            {
                MenuScreen energySourceScreen = r_Screens[eUIScreens.EnergySource] as MenuScreen;
                energySourceScreen.Display(out string energySourInput);
                energySourceType = (eEnergySource)parseMenuOption(energySourInput);
            }

            if (energySourceType == eEnergySource.Fuel)
            {
                MenuScreen FuelType = r_Screens[eUIScreens.FuelType] as MenuScreen;
                FuelType.Display(out string fuelTypeStr);
                eFuel fuel = (eFuel)parseMenuOption(fuelTypeStr);
                dataInputScreen.SetMassageToDisplay("Enter Fuel Tank Capacity");
                dataInputScreen.Display(out string fuelTankCapacity);
                float capacity = float.Parse(fuelTankCapacity);

                energySource = new FuelTank(fuel, capacity);
            }
            else
            {
                dataInputScreen.SetMassageToDisplay("Enter Maximum Time Capacity");
                dataInputScreen.Display(out string timeCapacity);
                float capacity = float.Parse(timeCapacity);

                energySource = new Battery(capacity);
            }

            return(energySource);
        }
示例#2
0
        private void addEnergy(string i_LicenseNumber, eEnergySource i_EnergySource)
        {
            NumericalInputScreen numericalInputScreen = r_Screens[eUIScreens.NumericalInput] as NumericalInputScreen;
            eFuel?fuel = null;

            if (i_EnergySource == eEnergySource.Electricity)
            {
                numericalInputScreen.SetMassageToDisplay("Enter Time To Add");
            }
            else
            {
                MenuScreen fuelScreen = r_Screens[eUIScreens.FuelType] as MenuScreen;
                fuelScreen.Display(out string fuelTypeStr);
                fuel = (eFuel)parseMenuOption(fuelTypeStr);
                numericalInputScreen.SetMassageToDisplay("Enter Amount of Fuel To Add");
            }

            numericalInputScreen.Display(out string energyToAddStr);
            float energyToAdd = float.Parse(energyToAddStr);

            try
            {
                if (i_EnergySource == eEnergySource.Electricity)
                {
                    r_GarageManager.ChargeVehicle(i_LicenseNumber, energyToAdd);
                }
                else
                {
                    r_GarageManager.FuelVehicle(i_LicenseNumber, fuel.Value, energyToAdd);
                }
            }
            catch (Exception exception)
            {
                ScreenUtils.Display(exception.ToString());
                ScreenUtils.Freeze();
            }
        }
示例#3
0
        private void vehicleActionHandler(VehicleInfo vehicleInfo, string userInput, out bool o_Back)
        {
            o_Back = false;
            string licenseNumber = vehicleInfo.Vehicle.LicenseNumber;

            eElectricityVehicleActionsOptions action = (eElectricityVehicleActionsOptions)parseMenuOption(userInput);

            switch (action)
            {
            case eElectricityVehicleActionsOptions.ChangeStatus:
                changeVehicleStatus(licenseNumber);
                break;

            case eElectricityVehicleActionsOptions.Inflate:
                inflate(licenseNumber);
                break;

            case eElectricityVehicleActionsOptions.Back:
                o_Back = true;
                break;

            case eElectricityVehicleActionsOptions.DisplayVehicle:
                displayVehicle(vehicleInfo);
                break;

            default:
                eEnergySource energySource = eEnergySource.Fuel;
                if (vehicleInfo.Vehicle.EnergySource is Battery)
                {
                    energySource = eEnergySource.Electricity;
                }

                addEnergy(licenseNumber, energySource);
                break;
            }
        }