Last active
October 12, 2017 13:56
-
-
Save rikuTanide/ab24a2f028e021b5d738d9489f3c423c to your computer and use it in GitHub Desktop.
状態変数にいろんなところからアクセスしている
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool aisatu = false; | |
int onigiriPrice = 100; | |
void onMessage(String message) { | |
switch (message) { | |
case "こんにちは": | |
onAisatu(); | |
return; | |
case "おにぎり3個ください": | |
onOnigiriRequest(); | |
return; | |
} | |
} | |
void onAisatu() { | |
print("こんにちは"); | |
aisatu = true; | |
} | |
void onOnigiriRequest() { | |
if (aisatu) { | |
var sum = onigiriPrice * 3; | |
print("$sum 円です"); | |
aisatu = false; | |
} | |
} | |
void setOnigiriPrice(int price) { | |
onigiriPrice = price; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment