Skip to content

Instantly share code, notes, and snippets.

@rikuTanide
Last active October 12, 2017 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rikuTanide/ab24a2f028e021b5d738d9489f3c423c to your computer and use it in GitHub Desktop.
Save rikuTanide/ab24a2f028e021b5d738d9489f3c423c to your computer and use it in GitHub Desktop.
状態変数にいろんなところからアクセスしている
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