def response
(statement
: String
): String
= { case x
if x.
isEmpty => "Fine. Be that way!" case x
if x.
matches("^[A-Z0-9][^a-z].+\\?$") => "Calm down, I know what I'm doing!" case x
if x.
matches("^.+\\?$") => "Sure." case x
if x.
matches ("^(?=[^A-Z\\n]*[A-Z])[^?\\n]+$") => "Whoa, chill out!" }
}
}
println(Bob.response("1, 2, 3 GO!"))
println(Bob.response("1, 2, 3"))
}
b2JqZWN0IE1haW4gZXh0ZW5kcyBBcHAgewoJb2JqZWN0IEJvYiB7CgkgIGRlZiByZXNwb25zZShzdGF0ZW1lbnQ6IFN0cmluZyk6IFN0cmluZyA9IHsKCSAgICBzdGF0ZW1lbnQudHJpbSgpIG1hdGNoIHsKCSAgICAgIGNhc2UgeCBpZiB4LmlzRW1wdHkgPT4gIkZpbmUuIEJlIHRoYXQgd2F5ISIKCSAgICAgIGNhc2UgeCBpZiB4Lm1hdGNoZXMoIl5bQS1aMC05XVteYS16XS4rXFw/JCIpID0+ICJDYWxtIGRvd24sIEkga25vdyB3aGF0IEknbSBkb2luZyEiCgkgICAgICBjYXNlIHggaWYgeC5tYXRjaGVzKCJeLitcXD8kIikgPT4gIlN1cmUuIgoJICAgICAgY2FzZSB4IGlmIHgubWF0Y2hlcyAoIl4oPz1bXkEtWlxcbl0qW0EtWl0pW14/XFxuXSskIikgPT4gIldob2EsIGNoaWxsIG91dCEiCgkgICAgICBjYXNlIF8gPT4gIldoYXRldmVyLiIKCSAgICB9CgkgIH0KCX0KCQoJcHJpbnRsbihCb2IucmVzcG9uc2UoIjEsIDIsIDMgR08hIikpCglwcmludGxuKEJvYi5yZXNwb25zZSgiMSwgMiwgMyIpKQp9