Skip to content

Instantly share code, notes, and snippets.

View Ah-da-Coder's full-sized avatar

Ah-da-Coder Ah-da-Coder

View GitHub Profile
@Ah-da-Coder
Ah-da-Coder / state.py(コメント付き)
Created March 13, 2020 14:41
StateパターンのPythonコード
class State():
"""Stateパターンの抽象クラス
"""
def action(self):
"""動作メソッド
Returns:
None
"""
@Ah-da-Coder
Ah-da-Coder / StatePatternSequenceDiagram_revised.pu
Created September 8, 2019 10:53
Stateパターンのシーケンス図改良版
@startuml
skinparam ClassAttributeIconSize 0
hide circle
hide empty member
main -> "<u>context</u>\n<u>:Context</u>" : <<create>>
"<u>context</u>\n<u>:Context</u>" -> "<u>the_beginning_of_the_day</u>\n<u>:TheBeginningOfTheDay</u>" : <<create>>
"<u>context</u>\n<u>:Context</u>" -> "<u>the_end_of_the_day</u>\n<u>:TheEndOfTheDay</u>" : <<create>>
@Ah-da-Coder
Ah-da-Coder / StatePatternSequenceDiagram.pu
Created September 8, 2019 06:53
Stateパターンのシーケンス図
@startuml
skinparam ClassAttributeIconSize 0
hide circle
hide empty member
main -> "<u>context</u>\n<u>:Context</u>" : <<create>>
"<u>context</u>\n<u>:Context</u>" -> "<u>the_beginning_of_the_day</u>\n<u>:TheBeginningOfTheDay</u>" : <<create>>
"<u>context</u>\n<u>:Context</u>" -> "<u>the_end_of_the_day</u>\n<u>:TheEndOfTheDay</u>" : <<create>>
@Ah-da-Coder
Ah-da-Coder / test_state.py
Created September 7, 2019 14:56
Stateパターンのテストコード
import unittest
from src.state import Context
class StateTest(unittest.TestCase):
def setUp(self):
self.context = Context()
def test_initial_state(self):
@Ah-da-Coder
Ah-da-Coder / state.py
Last active March 13, 2020 14:39
StatePatternのPythonコード
def main():
print("<<一日の始まり>>")
context = Context()
context.action()
context.greeting()
print("===")
print("<<一日の終わり>>")
context.change_state("一日の終わり")
@Ah-da-Coder
Ah-da-Coder / StatePatternDiagram.pu
Created September 7, 2019 12:45
StateパターンのUML
@startuml
skinparam ClassAttributeIconSize 0
hide circle
hide empty member
class Context {
state
change_state()
@startuml
left to right direction
skinparam packageStyle rect
actor 自分
rectangle ロボット {
自分 -- (利用)
}
@enduml
Zero
One
The End of Main Function...
// ReturnC_003_UserFunction.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#include "stdafx.h"
/* プロトタイプ宣言 */
int function_add_one(int num);
int _tmain(int argc, _TCHAR* argv[])
// ReternC_002_Variable.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
/* 変数 */
int num;