Example #1
0
        // check if the garage can handle with that king of vehicle
        private bool checkValidVehicle(Vehicle i_Vehicle)
        {
            bool               validFuelCar = false, validElectronicCar = false, validFuelMotor = false, validElectronicMotor = false, validTruck = false;
            FuelBaseCar        fuelBaseCar          = i_Vehicle as FuelBaseCar;
            ElectricCar        electronicCar        = i_Vehicle as ElectricCar;
            FuelBaseMotorcycle fuelBaseMotorcycle   = i_Vehicle as FuelBaseMotorcycle;
            ElectricMotorcycle electronicMotorcycle = i_Vehicle as ElectricMotorcycle;
            Truck              truck = i_Vehicle as Truck;

            if (fuelBaseCar != null)
            {
                validFuelCar = checkFuelBaseVehicleValid(
                    fuelBaseCar, r_FuelTypeGarageSupportForCarList, r_MaxFuelTankGarageSupportForFuelCarList,
                    r_NumOfWheelsGarageSupportForCarList, r_MaxAirPressureGarageSupportForCarList);
            }
            else if (electronicCar != null)
            {
                validElectronicCar = checkElectronicVehicleValid(
                    electronicCar, r_MaxBatteryTimeGarageSupportForElectricCarList,
                    r_NumOfWheelsGarageSupportForCarList, r_MaxAirPressureGarageSupportForCarList);
            }
            else if (fuelBaseMotorcycle != null)
            {
                validFuelMotor = checkFuelBaseVehicleValid(
                    fuelBaseMotorcycle, r_FuelTypeGarageSupportForMotorList, r_MaxFuelTankGarageSupportForFuelMotorList,
                    r_NumOfWheelsGarageSupportForMotorList, r_MaxAirPressureGarageSupportForMotorList);
            }
            else if (electronicMotorcycle != null)
            {
                validElectronicMotor = checkElectronicVehicleValid(
                    electronicMotorcycle, r_MaxBatteryTimeGarageSupportForElectricMotorList,
                    r_NumOfWheelsGarageSupportForMotorList, r_MaxAirPressureGarageSupportForMotorList);
            }
            else if (truck != null)
            {
                validTruck = checkFuelBaseVehicleValid(
                    truck, r_FuelTypeGarageSupportForTruckList, r_MaxFuelTankGarageSupportForTruckList,
                    r_NumOfWheelsGarageSupportForTruckList, r_MaxAirPressureGarageSupportForTruckList);
            }

            return(validFuelCar || validElectronicCar || validFuelMotor || validElectronicMotor || validTruck);
        }
        private bool handleMotocycleLicenseType(string i_Answer, Vehicle i_VehicleInSetting)
        {
            bool succeed = byte.TryParse(i_Answer, out byte licenseNumber);

            ElectricMotorcycle electricMotorcycle = i_VehicleInSetting as ElectricMotorcycle;
            FuelBaseMotorcycle fuelBaseMotorcycle = i_VehicleInSetting as FuelBaseMotorcycle;

            eLicenseType licenseType = ElectricMotorcycle.ConvertNumToLicenseType(licenseNumber);

            if (succeed && electricMotorcycle != null)
            {
                try
                {
                    electricMotorcycle.LicenseType = licenseType;
                    succeed = true;
                }
                catch
                {
                    succeed = false;
                }
            }
            else if (succeed && fuelBaseMotorcycle != null)
            {
                try
                {
                    fuelBaseMotorcycle.LicenseType = licenseType;
                    succeed = true;
                }
                catch
                {
                    succeed = false;
                }
            }
            else
            {
                succeed = false;
            }

            return(succeed);
        }
        private bool handleMotocycleEngineCapacity(string i_Answer, Vehicle i_VehicleInSetting)
        {
            bool succeed = int.TryParse(i_Answer, out int engineCapacity);

            ElectricMotorcycle electricMotorcycle = i_VehicleInSetting as ElectricMotorcycle;
            FuelBaseMotorcycle fuelBaseMotorcycle = i_VehicleInSetting as FuelBaseMotorcycle;

            if (succeed && electricMotorcycle != null)
            {
                try
                {
                    electricMotorcycle.EngineCapacity = engineCapacity;
                }
                catch
                {
                    succeed = false;
                }
            }
            else if (succeed && fuelBaseMotorcycle != null)
            {
                try
                {
                    fuelBaseMotorcycle.EngineCapacity = engineCapacity;
                }
                catch
                {
                    succeed = false;
                }
            }
            else
            {
                succeed = false;
            }

            return(succeed);
        }