sclass WaitForAnswer_YesNo { S question; pswappable S answer(S s) { if (isCancelCommand(s)) ret cancel(); if (isYes(s)) { cancelSilently(); ret processAnswer(true); } if "no" { cancelSilently(); ret processAnswer(false); } ret otherInput(s); } pswappable bool isYes(S s) { ret main isYes(s); } pswappable bool isNo(S s) { ret main isNo(s); } pswappable S otherInput(S s) { ret "I don't understand. Yes or no?"; } pswappable S processAnswer(bool yes) { ret "You said " + yesNo_short(yes); } pswappable bool isCancelCommand(S s) { ret match("cancel", s); } pswappable void cancelSilently() { print("Cancelling"); } pswappable S cancel() { cancelSilently(); ret "Action cancelled"; } }