type MathInterface interface {
Added() int
Subtract() int
}
type Math struct {
x, y int
}
func (m *Math) Add() int {
return m.x + m.y
}
func (m *Math) Subtract() int {
return m.x - m.y
}
type HandlerMath struct {
handler *Math
}
func NewMatch(math *Math) *HandlerMath {
return &HandlerMath{handler: math}
}
func main() {
data := NewMatch(&Math{})
data.handler.x = 5
data.handler.y = 3
added := data.handler.Add()
subtract := data.handler.Subtract()
fmt.Println(added)
fmt.Println(subtract)
}