- class Baseball {
- def strike = 0, ball = 0, out = 0
- def s = {
- if(2 < ++strike) {
- strike = 0; o()
- }
- }
- def b = {
- if(3 < ++ball) {
- h()
- }
- }
- def o = {
- if(2 < ++out) {
- strike = ball = out = 0
- }
- }
- def f = {
- if(strike < 2) {
- s()
- }
- }
- def h = { strike = ball = 0 }
- def p = { h(); o() }
- def resolve = {
- it.collect {
- this[it](); "$out$strike$ball"
- }.join(",")
- }
- }