simple_factory

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Circle

type Circle struct {
}

------- Circle

func (*Circle) Draw

func (c *Circle) Draw()

type Rectangle

type Rectangle struct {
}

------- Rectangle

func (*Rectangle) Draw

func (r *Rectangle) Draw()

type Shape

type Shape interface {
	Draw()
}

func NewShape

func NewShape(shape string) Shape

根据传入参数生产一个shape对象

type ShapeFactory

type ShapeFactory struct {
}

------- factory 也可以定义一个Shape Factory结构体,通过结构体方法来生产shape对象 上面的NewShape少写一些代码,这种方法可以在factory上再进行一些自定义

func (ShapeFactory) GetShape

func (sf ShapeFactory) GetShape(shape string) Shape

type Square

type Square struct {
}

------- Square

func (*Square) Draw

func (s *Square) Draw()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL