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.

56 lines
830 B
Go
Raw Normal View History

2018-01-01 17:05:45 +03:00
package composition
import (
"fmt"
)
type Driver interface {
Drive()
}
type Cleaner interface{
Clean()
}
type Killer interface {
Kill()
}
type Barker interface {
Bark()
}
type Dog struct {}
func (d *Dog) Bark() {
fmt.Println("Wow!")
}
type RobotDog struct {}
func (r *RobotDog) Drive() {
fmt.Println("Driving...")
}
func (r *RobotDog) Bark() {
fmt.Println("Wow!")
}
type CleanerRobotDog struct {}
func (r *CleanerRobotDog) Drive() {
fmt.Println("Driving...")
}
func (r *CleanerRobotDog) Bark() {
fmt.Println("Wow!")
}
func (r *CleanerRobotDog) Clean() {
fmt.Println("Cleaning...")
}
type KillerRobotDog struct {}
func (r *KillerRobotDog) Drive() {
fmt.Println("Driving...")
}
func (r *KillerRobotDog) Bark() {
fmt.Println("Wow!")
}
func (r *KillerRobotDog) Kill() {
fmt.Println("You gonna die!")
}