state1.txt
来自「C++课件,很好用的,帮助大家学习C++.」· 文本 代码 · 共 23 行
TXT
23 行
class Context{
private:
Color state;
void push(){
//如果当前red 状态 就切换到blue
if (state==Color.red) state=Color.blue;
//如果当前blue 状态 就切换到green
else if (state==Color.blue) state=Color.green;
//如果当前black 状态 就切换到red
else if (state==Color.black) state=Color.red;
//如果当前green 状态 就切换到black
else if (state==Color.green) state=Color.black;
Sample sample=new Sample(state);
}
void pull(){
//与push 状态切换正好相反
if (state==Color.green) state=Color.blue;
else if (state==Color.black) state=Color.green;
else if (state==Color.blue) state=Color.red;
else if (state==Color.red) state=Color.black;
Sample2 sample2=new Sample2(state);
}
};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?