Exemplo n.º 1
0
        public static Vehicle CreateNewVehicle(eVehicleType i_VehicleType, string i_LicenseNumber)
        {
            Vehicle newVehicle;

            switch (i_VehicleType)
            {
            case eVehicleType.FuelCar:
                newVehicle = new FuelCar(i_LicenseNumber);
                break;

            case eVehicleType.ElectricCar:
                newVehicle = new ElectricCar(i_LicenseNumber);
                break;

            case eVehicleType.FuelMotorbike:
                newVehicle = new FuelMotorbike(i_LicenseNumber);
                break;

            case eVehicleType.ElectricMotorbike:
                newVehicle = new ElectricMotorbike(i_LicenseNumber);
                break;

            case eVehicleType.Truck:
                newVehicle = new Truck(i_LicenseNumber);
                break;

            default:
                throw new ArgumentException("Invalid vehicle type");
            }

            return(newVehicle);
        }
Exemplo n.º 2
0
        public Vehicle MakeNewVehicle(eVehicleTypes vehicleType)
        {
            // this method get a vehicle type and return a new vehicle according to the type recieved.
            Vehicle newVehicle = null;

            switch (vehicleType)
            {
            case eVehicleTypes.ElectricCar:
                newVehicle = new ElectricCar();
                break;

            case eVehicleTypes.ElectricMotorbike:
                newVehicle = new ElectricMotorbike();
                break;

            case eVehicleTypes.EnginedCar:
                newVehicle = new EnginedCar();
                break;

            case eVehicleTypes.EnginedMotorbike:
                newVehicle = new EnginedMotorbike();
                break;

            case eVehicleTypes.Truck:
                newVehicle = new Truck();
                break;
            }

            return(newVehicle);
        }