-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
323 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,15 @@ | ||
package adapter | ||
|
||
type ChairPerson interface { | ||
OrganizeClass() | ||
} | ||
|
||
type TaroV2 struct { | ||
Taro | ||
} | ||
func main() { | ||
client := &client{} | ||
mac := &mac{} | ||
|
||
type Taro struct{} | ||
client.insertLightningConnectorIntoComputer(mac) | ||
|
||
func (s *TaroV2) OrganizationClass() { | ||
println("クラスの面倒みるよ") | ||
s.Taro.EnjoyWithClassmate() | ||
} | ||
windowsMachine := &windows{} | ||
windowsMachineAdapter := &windowsAdapter{ | ||
windowMachine: windowsMachine, | ||
} | ||
|
||
func (s *Taro) EnjoyWithClassmate() { | ||
println("わいわい") | ||
client.insertLightningConnectorIntoComputer(windowsMachineAdapter) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package adapter | ||
|
||
import "fmt" | ||
|
||
type client struct{} | ||
|
||
func (c *client) insertLightningConnectorIntoComputer(com computer) { | ||
fmt.Println("Client inserts Lightning connector into computer.") | ||
com.insertIntoLightningPort() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package adapter | ||
|
||
type computer interface { | ||
insertIntoLightningPort() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package adapter | ||
|
||
import "fmt" | ||
|
||
type mac struct { | ||
} | ||
|
||
func (m *mac) insertIntoLightningPort() { | ||
fmt.Println("Lightning connector is plugged into mac machine.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package adapter | ||
|
||
import "fmt" | ||
|
||
type windows struct{} | ||
|
||
func (w *windows) insertIntoUSBPort() { | ||
fmt.Println("USB connector is plugged into windows machine.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package adapter | ||
|
||
import "fmt" | ||
|
||
type windowsAdapter struct { | ||
windowMachine *windows | ||
} | ||
|
||
func (w *windowsAdapter) insertIntoLightningPort() { | ||
fmt.Println("Adapter converts Lightning signal to USB.") | ||
w.windowMachine.insertIntoUSBPort() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package prototype | ||
|
||
import "fmt" | ||
|
||
type file struct { | ||
name string | ||
} | ||
|
||
func (f *file) print(indentation string) { | ||
fmt.Println(indentation + f.name) | ||
} | ||
|
||
func (f *file) clone() inode { | ||
return &file{name: f.name + "_clone"} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package prototype | ||
|
||
import "fmt" | ||
|
||
type folder struct { | ||
children []inode | ||
name string | ||
} | ||
|
||
func (f *folder) print(indentation string) { | ||
fmt.Println(indentation + f.name) | ||
for _, i := range f.children { | ||
i.print(indentation + indentation) | ||
} | ||
} | ||
|
||
func (f *folder) clone() inode { | ||
cloneFolder := &folder{name: f.name + "_clone"} | ||
var tempChildren []inode | ||
for _, i := range f.children { | ||
copy := i.clone() | ||
tempChildren = append(tempChildren, copy) | ||
} | ||
cloneFolder.children = tempChildren | ||
return cloneFolder | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package prototype | ||
|
||
type inode interface { | ||
print(string) | ||
clone() inode | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.