factorymethod

package
v0.0.0-...-a7c7adb Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MinusOperator

type MinusOperator struct {
	*OperatorBase
}

MinusOperator Operator 的实际减法实现

func (MinusOperator) Result

func (o MinusOperator) Result() int

Result 获取结果

type MinusOperatorFactory

type MinusOperatorFactory struct{}

MinusOperatorFactory 是 MinusOperator 的工厂类

func (MinusOperatorFactory) Create

func (MinusOperatorFactory) Create() Operator

type Operator

type Operator interface {
	SetA(int)
	SetB(int)
	Result() int
}

Operator 是被封装的实际类接口,表示数学运算器应该有哪些行为

type OperatorBase

type OperatorBase struct {
	// contains filtered or unexported fields
}

OperatorBase 是Operator 接口实现的基类,封装公用方法

func (*OperatorBase) SetA

func (o *OperatorBase) SetA(a int)

SetA 设置 A

func (*OperatorBase) SetB

func (o *OperatorBase) SetB(b int)

SetB 设置 B

type OperatorFactory

type OperatorFactory interface {
	Create() Operator
}

OperatorFactory 是工厂接口

type PlusOperator

type PlusOperator struct {
	*OperatorBase
}

PlusOperator Operator 的实际加法实现

func (PlusOperator) Result

func (o PlusOperator) Result() int

Result 获取结果

type PlusOperatorFactory

type PlusOperatorFactory struct {
}

PlusOperatorFactory 是 PlusOperator 的工厂类

func (PlusOperatorFactory) Create

func (PlusOperatorFactory) Create() Operator

Jump to

Keyboard shortcuts

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