26 lines
419 B
Go
Raw Normal View History

2016-01-03 07:03:20 +02:00
package strategy
2015-12-23 15:46:15 +02:00
type Operator interface {
Apply(int, int) int
}
type Operation struct {
Operator Operator
}
func (o *Operation) Operate(leftValue, rightValue int) int {
return o.Operator.Apply(leftValue, rightValue)
}
type Multiplication struct{}
func (Multiplication) Apply(lval, rval int) int {
return lval * rval
}
type Addition struct{}
func (Addition) Apply(lval, rval int) int {
return lval + rval
}