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.

28 lines
630 B
Go
Raw Normal View History

2018-01-03 01:39:11 +03:00
package abstract_factory
import (
"fmt"
"errors"
)
const (
CAR = 1
BUS = 2
)
2019-03-09 23:38:10 +03:00
/**
* 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.
*/
2018-01-03 01:39:11 +03:00
func CreateVehicleFactory(vfType int) (VehicleFactory, error) {
switch vfType {
case CAR:
return new(CarFactory), nil
case BUS:
return new(BusFactory), nil
default:
2019-03-09 23:38:10 +03:00
return nil, errors.New(fmt.Sprintf("Unrecognized factory type:%d", vfType))
2018-01-03 01:39:11 +03:00
}
}