示例#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 handleCarDoorNumber(string i_Answer, Vehicle i_VehicleInSetting)
        {
            bool succeed = byte.TryParse(i_Answer, out byte doorNumberInByte);

            ElectricCar electricCar = i_VehicleInSetting as ElectricCar;
            FuelBaseCar fuelCar     = i_VehicleInSetting as FuelBaseCar;

            eDoorsNumber doorNumber = ElectricCar.CovertNumToDoorNumber(doorNumberInByte);

            if (succeed && fuelCar != null)
            {
                try
                {
                    fuelCar.DoorsNumber = doorNumber;
                    succeed             = true;
                }
                catch
                {
                    succeed = false;
                }
            }
            else if (succeed && electricCar != null)
            {
                try
                {
                    electricCar.DoorsNumber = doorNumber;
                    succeed = true;
                }
                catch
                {
                    succeed = false;
                }
            }
            else
            {
                succeed = false;
            }

            return(succeed);
        }
        private bool handleCarColor(string i_Answer, Vehicle i_VehicleInSetting)
        {
            bool succeed = byte.TryParse(i_Answer, out byte colorNumber);

            ElectricCar electricCar = i_VehicleInSetting as ElectricCar;
            FuelBaseCar fuelCar     = i_VehicleInSetting as FuelBaseCar;

            eColor color = ElectricCar.CovertNumToColor(colorNumber);

            if (succeed && fuelCar != null)
            {
                try
                {
                    fuelCar.Color = color;
                    succeed       = true;
                }
                catch
                {
                    succeed = false;
                }
            }
            else if (succeed && electricCar != null)
            {
                try
                {
                    electricCar.Color = color;
                    succeed           = true;
                }
                catch
                {
                    succeed = false;
                }
            }
            else
            {
                succeed = false;
            }

            return(succeed);
        }