This repository has been archived on 2021-09-07. You can view files and clone it, but cannot push or open issues or pull requests.
2019-03-09 23:38:10 +03:00

26 lines
461 B
Go

package abstract_factory
import (
"fmt"
"errors"
)
const (
MICRO_BUS = 1
CITY_TOUR_BUS = 2
)
type BusFactory struct {}
// Creates vehicles which is member of Bus subfamily group
func(f *BusFactory) NewVehicle(busType int)(Vehiche, error) {
switch busType {
case CITY_TOUR_BUS:
return new(CityTourBus), nil
case MICRO_BUS:
return new(MicroBus), nil
default:
return nil, errors.New(fmt.Sprintf("Unsupported bus vehicle type:%d", busType))
}
}