设计模式
2021-01-17 17:23:03 1 举报
设计模式UML示例图 博客发表在:https://www.cnblogs.com/greyzeng/p/14107751.html
作者其他创作
大纲/内容
SenstiveFilter
+ doFilter(Msg msg):boolean
代理模式之静态代理,类似与装饰器模式
GiftImpl
BasketballGame
+ init()+ start()+ play()+ end()
Tank
+ move()+ go()
Client
+ labour: LabourContractor
博客:https://www.cnblogs.com/greyzeng/p/15775683.html
0..*
User
- name:String
+ getName():String+ setName(name)+ inputMessage(message)
InvocationHandler
Transportation
+ go():void
RedSharpDecorator
+ decoratedSharp:Sharp
+ draw():void
HappyState
+ cry()+ smile()+ say()
Node
+ content:String
+ print():void
Memory
+ accept(Visitor visitor)+ getPrice(): int
Iterator_<E>
+ hasNext():boolean+ next(): E
组合模式
状态模式
+ move()
SadState
moveable
CPU
门面/外观模式
CarFactory
+ create()
工厂方法
Coach
AbstractFactory
+ createTransportation ():Transportation + createWritingInstrument ():WritingInstrument
Circle
MediaPlayer
模板方法
Main
+ factory:AbstractFactory
+ factory:CarFactory
AVIPlayer
+ playAVI(String fileName)
Sharp
+ draw()
Rectangle
AdvanceMediaPlayer
+ playMP4(String fileName)+ playAVI(String fileName)
TankLogProxy
- m: Moveable
+ move()+ TankLogProxy(Moveable m)
Gift
+ GiftImpl: impl
CorpVisitor
- totalPrice:int
+ visitCpu(CPU cpu) + visitMemory(Memory memory) + visitBoard(Board board)+getTotalPrice():int
Moveable
调停/中介模式
AncientFactory
ArrayList_<E>
- objects :E[]- index:int- iterator: ArrayListIterator_
+ add(E e)+ size()+ iterator():Iterator
Abstract Game
+ init()+ start()+ play()+ end()
Flower
Listener1
+ actionPerformed(ActionEvent event):void
BranchNode
+ nodes:List<Node>
+ print():void+ addNode(Node node)
Location
+ street: String+ roomNo: int
代理模式之动态代理,实现InvocationHandler(JDK自带)必须面向接口!!!!
ChatRoom
+ showMessage(String)
BrickWorker
+ carry()
适配器模式
桥接模式
Msg
- content:String
+ getContent():String+ setContent()_
ArrayListIterator_<E>
- currentIndex:int
PlayerAdapter
+advanceMediaPlayer: AdvanceMediaPlayer
Serializable
Button
+ listeners:List<ActionListner>
+ addActionListener(ActionListener)+ buttonPressed()
CopyCommand
+ content:Content
+ doit()+ undo()+ CopyCommand(Content content)
Bullet
+ uuid:UUID+ living:boolean
+ toString():String
MM
+ state:State
+ cry()+ smile()+ say()+ MM(State state)
访问者模式
ActionListner
Command
+ doit()+ undo()
装饰器模式
命令模式
Bus
备忘录模式模拟游戏存盘
Car
HTMLFilter
Visitor
+ visitCpu(CPU cpu) + visitMemory(Memory memory) + visitBoard(Board board)
Brush
+ write():void
ModernFactory
+ createTransportation ():Transportation + createWritingInstrument ():WritingInstrument
Cloneable
Pen
Board
代码:https://github.com/GreyZeng/dp
Collection_<E>
SharpDecorator
LeafNode
+ print():void+ LeafNode(String content)
原型模式Object.clone() 要特别注意深浅拷贝的问题
ClassicMediaPlayer
State
BulletPool
+ bullets:List<Bullet>
+ getBullet(): Bullet
*..0
FootballGame
Mason
+ mix()
构造器模式
享元模式
ComputerPart
WritingInstrument
FilterChain
+ chains:List<Filter>
+ add(Filter filter)+ doFilter(Msg)
MP4Player
+ playMP4(String fileName)
WarmGift
+ WarmGift(GiftImpl impl)
观察者模式
PersonVisitor
+ visitCpu(CPU cpu) + visitMemory(Memory memory) + visitBoard(Board board)+ getTotalPrice():int
WildGift
+ WildGift(GiftImpl impl)
LabourContractor
+ work1: Mason+ work2: BrickWorker+ work3: BrickLayer
+buildHouse()
ExtendMediaPlayer
+ adapter:PlayerAdapter
ActionEvent
- when:long- source:Object
Content
+ msg: String
迭代器模式
BrickLayer
+ neat()
TankTimeProxy
- m: Moveable
+ move()+ TankTimeProxy(Moveable m)
抽象工厂
Filter
Builder
- servingSize:int- servings:int- calories:int- fat:int- sodium:int- carbohydrate:int
+ build()+ servingSize()+ servings()+ calories()+ fat()+ sodium()+ carbohydrate()
责任链模式
MovableProxy
- movable: Movable
+ getMovable(): Movable+ setMovable(Movable movable)+ MovableProxy(Moveable movable)span style=\"font-size: inherit;\
Person
+ name:String+ age:int
+ toString()
Book
+ age: int+ name: String+ loc: Location
+ clone():Object
NutritionFacts
- NutritionFacts(Builder builder)
+ load()+ save(Person person)
0 条评论
下一页