Commit f46cac2c authored by Boris Mühmer's avatar Boris Mühmer
Browse files

playing with interfaces

parent 030b4566
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -2,5 +2,17 @@ package avatar

// Avatar is a player character in the MUOG world.
type Avatar struct {
	Name string
	name string
}

// Name returns the name of the avatar.
func (a *Avatar) Name() string {
	return a.name
}

// SetName changes the name of an avatar and returns the old one.
func (a *Avatar) SetName(name string) (string, error) {
	oldName := a.name
	a.name = name
	return oldName, nil
}
+11 −0
Original line number Diff line number Diff line
package entity

// ActiveObjecter describes actions
type ActiveObjecter interface {
	//
}

// InactiveObjecter describes something
type InactiveObjecter interface {
	//
}
+7 −0
Original line number Diff line number Diff line
package model

// Character is a person, monster, or anything that can do actions.
type Character interface {
	Name() string
	SetName(string) (string, error)
}
+6 −0
Original line number Diff line number Diff line
package model

// Objecter is an inactive thing, that can not act on its own.
type Objecter interface {
	Name() string
}
+11 −0
Original line number Diff line number Diff line
package object

// BottleOfBeer is a bottle of beer.
type BottleOfBeer struct {
	name string
}

// Name returns the name of ths bottle of beer.
func (b *BottleOfBeer) Name() string {
	return b.name
}
Loading