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
463 B
Go

package abstract_factory
import (
"errors"
"fmt"
)
const (
OFFROADER_CAR = 1
SPORT_CAR = 2
)
type CarFactory struct{}
// Creates vehicles which is member of Car subfamily group
func (f *CarFactory) NewVehicle(carType int) (Vehiche, error) {
switch carType {
case OFFROADER_CAR:
return new(Offroader), nil
case SPORT_CAR:
return new(Sportcar), nil
default:
return nil, errors.New(fmt.Sprintf("Unsupported car vehicle type:%d", carType))
}
}