Factory Method
package pokemon
// Pokemon has a list of moves and attack.
type Pokemon interface {
Moves() []string
Attack() error
Level() uint
}
type charmander struct {
// List of attributes
}
func (c *charmander) Moves() []string {
return []string{}
}
func (c *charmander) Attack() error {
return nil
}
func (c *charmander) Level() uint {
return c.level
}
type squirtle struct {
// List of attributes
}
func (s *squirtle) Moves() []string {
return []string{}
}
func (s *squirtle) Attack() error {
return nil
}
func (s *squirtle) Level() uint {
return s.level
}Last updated