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

28 lines
630 B
Go

package abstract_factory
import (
"fmt"
"errors"
)
const (
CAR = 1
BUS = 2
)
/**
* CreateVehicleFactory function makes subfamily factories of Vehicle
* family. The goal is to split object family creation complexity
* into small blocks in order to make it easy to read and maintain.
* It basicaly delegates subfamily object creations to subfamily factories.
*/
func CreateVehicleFactory(vfType int) (VehicleFactory, error) {
switch vfType {
case CAR:
return new(CarFactory), nil
case BUS:
return new(BusFactory), nil
default:
return nil, errors.New(fmt.Sprintf("Unrecognized factory type:%d", vfType))
}
}