GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Unity3DTraining/DesignPatterns/StatePattern at master · UnitySample/Unity3DTraining

Expand file tree

/

StatePattern

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
 
 
/

StatePattern

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
StatePattern
StatePattern
 
 
README.md
README.md
 
 
StatePattern.sln
StatePattern.sln
 
 

README.md

Outline

状态模式

定义

当一个对象的内在状态改变时,允许改变其行为,这个对象看起来像是改变了其类。

小结  

一个对象的状态就是这个对象的属性值的组合,如果我们改变了这些属性的任意一个,那么对象的状态就发生了改变。一般地,调用一个对象的方法时都会改变这个对象的状态,因为这个方法往往会调用并改变自己的属性。
状态模式适用于下面的情况:  

  • 当一个对象的行为取决于它的状态并且它必须在运行时刻根据状态来改变自己的行为时;
  • 当一个操作中含有大量的分支条件语句时,并且这些分支都依赖于该对象的状态时
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.