東方算程譚

Oriental Code Talk ── επιστημηが与太をこく、弾幕とは無縁のシロモノ。

目次

Blog 利用状況

ニュース

著作とお薦めの品々は

著作とお薦めの品々は
東方熱帯林へ。

あわせて読みたい

わんくま

  1. 東京勉強会#2
    C++/CLI カクテル・レシピ
  2. 東京勉強会#3
    template vs. generics
  3. 大阪勉強会#6
    C++むかしばなし
  4. 東京勉強会#7
    C++むかしばなし
  5. 東京勉強会#8
    STL/CLRによるGeneric Programming
  6. TechEd 2007 @YOKOHAMA
    C++・C++/CLI・C# 適材適所
  7. 東京勉強会#14
    Making of BOF
  8. 東京勉強会#15
    状態遷移
  9. 名古屋勉強会#2
    WinUnit - お気楽お手軽UnitTest

CodeZine

  1. Cで実現する「ぷちオブジェクト指向」
  2. CUnitによるテスト駆動開発
  3. SQLiteで組み込みDB体験(2007年版)
  4. C++/CLIによるCライブラリの.NET化
  5. C# 1.1からC# 3.0まで~言語仕様の進化
  6. BoostでC++0xのライブラリ「TR1」を先取りしよう (1)
  7. BoostでC++0xのライブラリ「TR1」を先取りしよう (2)
  8. BoostでC++0xのライブラリ「TR1」を先取りしよう (3)
  9. BoostでC++0xのライブラリ「TR1」を先取りしよう (4)
  10. BoostでC++0xのライブラリ「TR1」を先取りしよう (5)
  11. C/C++に対応した、もうひとつのUnitTestFramework ─ WinUnit
  12. SQLiteで"おこづかいちょう"
  13. STL/CLRツアーガイド
  14. マージ・ソート : 巨大データのソート法
  15. ヒープソートのアルゴリズム
  16. C++0xの新機能「ラムダ式」を次期Visual Studioでいち早く試す
  17. .NETでマンデルブロ集合を描く
  18. .NETでマンデルブロ集合を描く(後日談)
  19. C++/CLI : とある文字列の相互変換(コンバージョン)
  20. インテルTBBによる選択ソートの高速化
  21. インテルTBB3.0 によるパイプライン処理
  22. Visual C++ 2010に追加されたSTLアルゴリズム
  23. Visual C++ 2010に追加されたSTLコンテナ「forward_list」
  24. shared_ptrによるObserverパターンの実装
  25. .NETでマンデルブロ集合を描く(番外編) ── OpenCLで超並列コンピューティング
  26. StateパターンでCSVを読む
  27. 状態遷移表からStateパターンを自動生成する
  28. 「ソートも、サーチも、あるんだよ」~標準C++ライブラリにみるアルゴリズムの面白さ
  29. インテルTBBの同期メカニズム
  30. なぜsetを使っちゃいけないの?
  31. WPFアプリケーションで腕試し ~C++でもWPFアプリを
  32. C++11 : スレッド・ライブラリひとめぐり
  33. Google製のC++ Unit Test Framework「Google Test」を使ってみる
  34. メールでデータベースを更新するココロミ
  35. Visitorパターンで遊んでみたよ
  36. Collection 2題:「WPFにバインドできる辞書」と「重複を許す検索set」
  37. Visual C++ 2012:stateless-lambdaとSQLiteのぷち拡張
  38. 「Visual C++ Compiler November 2012 CTP」で追加された6つの新機能

@IT

  1. Vista時代のVisual C++の流儀(前編)Vista到来。既存C/C++資産の.NET化を始めよう!
  2. Vista時代のVisual C++の流儀(中編)MFCから.NETへの実践的移行計画
  3. Vista時代のVisual C++の流儀(後編) STL/CLRによるDocument/Viewアーキテクチャ
  4. C++開発者のための単体テスト入門 第1回 C++開発者の皆さん。テスト、ちゃんとしていますか?
  5. C++開発者のための単体テスト入門 第2回 C++アプリケーションの効率的なテスト手法(CppUnit編)
  6. C++開発者のための単体テスト入門 第3回 C++アプリケーションの効率的なテスト手法(NUnit編)

AWARDS


Microsoft MVP
for Visual Developer - Visual C++


Wankuma MVP
for いぢわる C++


Nyantora MVP
for こくまろ中国茶

Xbox

Links

記事カテゴリ

書庫

日記カテゴリ

状態遷移ってばこの程度のもの

ネタ元 → 電卓アプリの状態遷移図

オブジェクト指向してない電卓のつくりかた
アクアさんとこにあった状態遷移図を表にするとこーなる↓

電卓基本動作の状態遷移表
初期状態 数値入力状態 数式作成状態 計算結果表示状態
数字入力 なにかする
数値入力状態
なにかする
数値入力状態
なにかする
数値入力状態
なにかする
数値入力状態
演算子入力 なにかする
初期状態
なにかする
数式作成状態
なにかする
数式作成状態
なにかする
数式作成状態
'='入力 なにかする
初期状態
なにかする
計算結果表示状態
なにかする
計算結果表示状態
なにかする
計算結果表示状態
'C'入力 なにかする
初期状態
なにかする
初期状態
なにかする
初期状態
なにかする
初期状態


読み方はわかるよね、たとえば左上隅のマスは:
初期状態で数字入力されたらなにかして数値入力状態に遷移せよ」ってことね。

つまり、状態遷移は
(状態、事象、動作、遷移) の集合です。
もっといえば、「なんかする」と「次の状態」を要素とする
二次元配列 状態遷移表[状態数][事象数] で表現できます。
試験にでるよー でねーよ

各マスの「なんかする」をテケトーに実装し、
状態初期状態にセットして準備完了。
あとはボタンが押されるたんびに:

 事象 = ボタンに割り当てられたデキゴト;
 状態遷移表[状態][事象].なんかする();
 状態 = 状態遷移表[状態][事象].次の状態;

↑これを繰り返せば電卓なんかあっちゅーまに動きますぶっちゃけ

あとはほんのちょっとのヒマと「いぢわるスタヂオ2005」と
しょっきんぐぴんくまを用意すれば電卓祭りの神輿が担げます。
お祭りワショーイ

投稿日時 : 2007年7月12日 10:02

コメントを追加

# re: 状態遷移ってばこの程度のもの 2007/07/12 12:53 通り*

勉強になるなぁ~
こうやって表になったのを見ると、状態と事象をコレクションか何かに設定して、それぞれの「何かする」でイベントが発生するようにすれば、ハンドラを実装するだけでちゃんと動くようになるフレームワーク(コントロール?)とかも作れたりしないかなって思いました。
あ、これだけだとコントロールにするほどでもないかな...

# re: 状態遷移ってばこの程度のもの 2007/07/12 13:16 επιστημη

つ【http://www.s34.co.jp/cpptechdoc/article/xml/fsmgen/index.html

# re: 状態遷移ってばこの程度のもの 2007/07/12 13:51 通り*

私のアイデア既に盗まれてる!(違w
でも、私の想像より遙かに凄いことになってますね。
ぎゅっとまとめると、
状態遷移表を表現するDTDに従ったXMLで状態遷移を定義し、XSLで資料を出力し、"STATEパターン"でフレームワークを作成し、最後にそれを利用する、ってことみたい。。。?
頭がパンクしそうですw
これでどなたか電卓作って見せてください!><(C#希望)
#ところでアクションがThankYouって、横領?w

# re: 状態遷移ってばこの程度のもの 2007/07/12 14:42 επιστημη

6年ほど前に書いたやつです。
今ならSystem.Xml 使ってほいほい書けちゃうでしょねー。
なんかのついでにC#でre-writeしたいと思いながら今に至っておりますなり orz

# re: 状態遷移ってばこの程度のもの 2007/07/12 16:02 通り*

6年も前に盗まれてた!(違違w
お時間あるときに、またお願いします。vote=1
#つ【祭りのついで】

# re: 状態遷移ってばこの程度のもの 2007/07/12 22:03 επιστημη

そーそー、モノによっては"なんかする"の結果次第で遷移先が変化するばあいがあります。
んなときゃ"なんかする"が次の状態を返すことにして:
状態 = 状態遷移表[状態][事象].なんかする();
ってやるですね。

あ…表は真四角だからJAG配列でなくていいか。
状態 = 状態遷移表[状態,事象].なんかする();
の方が楽ね。

# 15Calc電卓ソースコード公開~ 2007/08/03 0:49 XAMLab(ザムラボ)

15Calc電卓ソースコード公開~

# 電卓の話で妄想したこと 2008/03/17 22:19 凪瀬 Blog

電卓の話で妄想したこと

# ジェネリクスを最大限活用するための設計技法 Stateパターン編 2008/08/20 0:10 凪瀬 Blog

ジェネリクスを最大限活用するための設計技法 Stateパターン編

# re: ?????????????? 2021/08/07 9:37 can hydroxychloroquine cause blindness

chloroquine phosphate tablet https://chloroquineorigin.com/# hydroxychloroquinone

# My brother recommended I might like this website. He was entirely right. This post actually made my day. You cann't imagine simply how much time I had spent for this info! Thanks! 2021/08/28 23:05 My brother recommended I might like this website.

My brother recommended I might like this website.

He was entirely right. This post actually made my day.
You cann't imagine simply how much time I had spent for this info!
Thanks!

# My brother recommended I might like this website. He was entirely right. This post actually made my day. You cann't imagine simply how much time I had spent for this info! Thanks! 2021/08/28 23:06 My brother recommended I might like this website.

My brother recommended I might like this website.

He was entirely right. This post actually made my day.
You cann't imagine simply how much time I had spent for this info!
Thanks!

# My brother recommended I might like this website. He was entirely right. This post actually made my day. You cann't imagine simply how much time I had spent for this info! Thanks! 2021/08/28 23:07 My brother recommended I might like this website.

My brother recommended I might like this website.

He was entirely right. This post actually made my day.
You cann't imagine simply how much time I had spent for this info!
Thanks!

# My brother recommended I might like this website. He was entirely right. This post actually made my day. You cann't imagine simply how much time I had spent for this info! Thanks! 2021/08/28 23:08 My brother recommended I might like this website.

My brother recommended I might like this website.

He was entirely right. This post actually made my day.
You cann't imagine simply how much time I had spent for this info!
Thanks!

# This article is truly a fastidious one it assists new the web visitors, who are wishing in favor of blogging. 2021/08/30 3:27 This article is truly a fastidious one it assists

This article is truly a fastidious one it assists new the web visitors, who
are wishing in favor of blogging.

# Hello my family member! I wish to say that this post is amazing, great written and come with almost all vital infos. I'd like to see more posts like this . 2021/08/31 17:32 Hello my family member! I wish to say that this po

Hello my family member! I wish to say that this post is amazing, great written and come with almost all
vital infos. I'd like to see more posts like this .

# Hello my family member! I wish to say that this post is amazing, great written and come with almost all vital infos. I'd like to see more posts like this . 2021/08/31 17:33 Hello my family member! I wish to say that this po

Hello my family member! I wish to say that this post is amazing, great written and come with almost all
vital infos. I'd like to see more posts like this .

# Hello my family member! I wish to say that this post is amazing, great written and come with almost all vital infos. I'd like to see more posts like this . 2021/08/31 17:34 Hello my family member! I wish to say that this po

Hello my family member! I wish to say that this post is amazing, great written and come with almost all
vital infos. I'd like to see more posts like this .

# Hello my family member! I wish to say that this post is amazing, great written and come with almost all vital infos. I'd like to see more posts like this . 2021/08/31 17:35 Hello my family member! I wish to say that this po

Hello my family member! I wish to say that this post is amazing, great written and come with almost all
vital infos. I'd like to see more posts like this .

# It's remarkable to visit this web page and reading the views of all colleagues concerning this paragraph, while I am also keen of getting knowledge. 2021/09/04 16:19 It's remarkable to visit this web page and reading

It's remarkable to visit this web page and reading the views
of all colleagues concerning this paragraph, while I am also keen of getting knowledge.

# It's remarkable to visit this web page and reading the views of all colleagues concerning this paragraph, while I am also keen of getting knowledge. 2021/09/04 16:20 It's remarkable to visit this web page and reading

It's remarkable to visit this web page and reading the views
of all colleagues concerning this paragraph, while I am also keen of getting knowledge.

# It's remarkable to visit this web page and reading the views of all colleagues concerning this paragraph, while I am also keen of getting knowledge. 2021/09/04 16:21 It's remarkable to visit this web page and reading

It's remarkable to visit this web page and reading the views
of all colleagues concerning this paragraph, while I am also keen of getting knowledge.

# It's remarkable to visit this web page and reading the views of all colleagues concerning this paragraph, while I am also keen of getting knowledge. 2021/09/04 16:22 It's remarkable to visit this web page and reading

It's remarkable to visit this web page and reading the views
of all colleagues concerning this paragraph, while I am also keen of getting knowledge.

# Hi friends, how is the whole thing, and what you wish for to say on the topic of this article, in my view its really awesome designed for me. 2021/09/06 10:35 Hi friends, how is the whole thing, and what you w

Hi friends, how is the whole thing, and what
you wish for to say on the topic of this article, in my view its really awesome
designed for me.

# Hi friends, how is the whole thing, and what you wish for to say on the topic of this article, in my view its really awesome designed for me. 2021/09/06 10:36 Hi friends, how is the whole thing, and what you w

Hi friends, how is the whole thing, and what
you wish for to say on the topic of this article, in my view its really awesome
designed for me.

# Hi friends, how is the whole thing, and what you wish for to say on the topic of this article, in my view its really awesome designed for me. 2021/09/06 10:37 Hi friends, how is the whole thing, and what you w

Hi friends, how is the whole thing, and what
you wish for to say on the topic of this article, in my view its really awesome
designed for me.

# Hi friends, how is the whole thing, and what you wish for to say on the topic of this article, in my view its really awesome designed for me. 2021/09/06 10:38 Hi friends, how is the whole thing, and what you w

Hi friends, how is the whole thing, and what
you wish for to say on the topic of this article, in my view its really awesome
designed for me.

# Hello all, here every one is sharing these kinds of knowledge, so it's good to read this blog, and I used to pay a quick visit this website daily. 2021/09/06 10:53 Hello all, here every one is sharing these kinds o

Hello all, here every one is sharing these kinds of
knowledge, so it's good to read this blog,
and I used to pay a quick visit this website daily.

# Hello all, here every one is sharing these kinds of knowledge, so it's good to read this blog, and I used to pay a quick visit this website daily. 2021/09/06 10:54 Hello all, here every one is sharing these kinds o

Hello all, here every one is sharing these kinds of
knowledge, so it's good to read this blog,
and I used to pay a quick visit this website daily.

# Hello all, here every one is sharing these kinds of knowledge, so it's good to read this blog, and I used to pay a quick visit this website daily. 2021/09/06 10:55 Hello all, here every one is sharing these kinds o

Hello all, here every one is sharing these kinds of
knowledge, so it's good to read this blog,
and I used to pay a quick visit this website daily.

# Hello all, here every one is sharing these kinds of knowledge, so it's good to read this blog, and I used to pay a quick visit this website daily. 2021/09/06 10:56 Hello all, here every one is sharing these kinds o

Hello all, here every one is sharing these kinds of
knowledge, so it's good to read this blog,
and I used to pay a quick visit this website daily.

# Hello, all is going sound here and ofcourse every one is sharing information, that's truly fine, keep up writing. quest bars http://bitly.com/3jZgEA2 quest bars 2021/09/11 23:55 Hello, all is going sound here and ofcourse every

Hello, all is going sound here and ofcourse every one is sharing information, that's truly fine,
keep up writing. quest bars http://bitly.com/3jZgEA2 quest bars

# I think this is one of the most significant information for me. And i'm glad reading your article. But wanna remark on some general things, The web site style is great, the articles is really excellent : D. Good job, cheers part time jobs hired in 30 m 2021/10/22 23:05 I think this is one of the most significant inform

I think this is one of the most significant information for me.
And i'm glad reading your article. But wanna remark on some general things, The web site
style is great, the articles is really excellent : D.

Good job, cheers part time jobs hired in 30 minutes https://parttimejobshiredin30minutes.wildapricot.org/

# Wow! This blog looks exactly like my old one! It's on a entirely different topic but it has pretty much the same page layout and design. Great choice of colors! 2021/10/26 16:59 Wow! This blog looks exactly like my old one! It's

Wow! This blog looks exactly like my old one! It's on a
entirely different topic but it has pretty much the same page
layout and design. Great choice of colors!

# Wow! This blog looks exactly like my old one! It's on a entirely different topic but it has pretty much the same page layout and design. Great choice of colors! 2021/10/26 17:00 Wow! This blog looks exactly like my old one! It's

Wow! This blog looks exactly like my old one! It's on a
entirely different topic but it has pretty much the same page
layout and design. Great choice of colors!

# Wow! This blog looks exactly like my old one! It's on a entirely different topic but it has pretty much the same page layout and design. Great choice of colors! 2021/10/26 17:01 Wow! This blog looks exactly like my old one! It's

Wow! This blog looks exactly like my old one! It's on a
entirely different topic but it has pretty much the same page
layout and design. Great choice of colors!

# Wow! This blog looks exactly like my old one! It's on a entirely different topic but it has pretty much the same page layout and design. Great choice of colors! 2021/10/26 17:02 Wow! This blog looks exactly like my old one! It's

Wow! This blog looks exactly like my old one! It's on a
entirely different topic but it has pretty much the same page
layout and design. Great choice of colors!

# I all the time emailed this blog post page to all my associates, because if like to read it afterward my friends will too. 2021/11/12 10:40 I all the time emailed this blog post page to all

I all the time emailed this blog post page to all my
associates, because if like to read it afterward
my friends will too.

タイトル
名前
URL
コメント