mirror of
https://github.com/tmrts/go-patterns.git
synced 2024-11-28 16:06:07 +03:00
creational/builder: change wheels to more appropriate
Sports car is expected to have sports wheels, while family car may have steel wheels
This commit is contained in:
parent
f978e42036
commit
b3eb3225a6
@ -53,9 +53,9 @@ type Interface interface {
|
|||||||
```go
|
```go
|
||||||
assembly := car.NewBuilder().Paint(car.RedColor)
|
assembly := car.NewBuilder().Paint(car.RedColor)
|
||||||
|
|
||||||
familyCar := assembly.Wheels(car.SportsWheels).TopSpeed(50 * car.MPH).Build()
|
familyCar := assembly.Wheels(car.SteelWheels).TopSpeed(50 * car.MPH).Build()
|
||||||
familyCar.Drive()
|
familyCar.Drive()
|
||||||
|
|
||||||
sportsCar := assembly.Wheels(car.SteelWheels).TopSpeed(150 * car.MPH).Build()
|
sportsCar := assembly.Wheels(car.SportsWheels).TopSpeed(150 * car.MPH).Build()
|
||||||
sportsCar.Drive()
|
sportsCar.Drive()
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user