Skip to content

Commit

Permalink
update builder mode
Browse files Browse the repository at this point in the history
  • Loading branch information
senghoo committed Mar 30, 2016
1 parent ae14ae7 commit a93ad36
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 40 deletions.
40 changes: 40 additions & 0 deletions 06_builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,43 @@ func (d *Director) Construct() {
d.builder.Part2()
d.builder.Part3()
}

type Builder1 struct {
result string
}

func (b *Builder1) Part1() {
b.result += "1"
}

func (b *Builder1) Part2() {
b.result += "2"
}

func (b *Builder1) Part3() {
b.result += "3"
}

func (b *Builder1) GetResult() string {
return b.result
}

type Builder2 struct {
result int
}

func (b *Builder2) Part1() {
b.result += 1
}

func (b *Builder2) Part2() {
b.result += 2
}

func (b *Builder2) Part3() {
b.result += 3
}

func (b *Builder2) GetResult() int {
return b.result
}
40 changes: 0 additions & 40 deletions 06_builder/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,6 @@ package builder

import "testing"

type Builder1 struct {
result string
}

func (b *Builder1) Part1() {
b.result += "1"
}

func (b *Builder1) Part2() {
b.result += "2"
}

func (b *Builder1) Part3() {
b.result += "3"
}

func (b *Builder1) GetResult() string {
return b.result
}

func TestBuilder1(t *testing.T) {
builder := &Builder1{}
director := NewDirector(builder)
Expand All @@ -32,26 +12,6 @@ func TestBuilder1(t *testing.T) {
}
}

type Builder2 struct {
result int
}

func (b *Builder2) Part1() {
b.result += 1
}

func (b *Builder2) Part2() {
b.result += 2
}

func (b *Builder2) Part3() {
b.result += 3
}

func (b *Builder2) GetResult() int {
return b.result
}

func TestBuilder2(t *testing.T) {
builder := &Builder2{}
director := NewDirector(builder)
Expand Down

0 comments on commit a93ad36

Please sign in to comment.