가드조건
2026년 2월 12일 12:40분
package com.jesusbornd.exodus;
public class Exodus_32_Chapter_Lv3 {
public static class StateMachine {
public static final String OK = "언약 / Covenant";
public static final String BROKEN = "파기 / Broken";
public static final String RESTORED = "회복 / Restored";
private String state = OK;
public void breakIt() {
state = BROKEN;
}
public void restore() {
if (BROKEN.equals(state)) state = RESTORED;
}
public String state() {
return state;
}
}
public static void main(String[] args) {
StateMachine sm = new StateMachine();
System.out.println(sm.state());
sm.breakIt();
System.out.println(sm.state());
sm.restore();
System.out.println(sm.state());
}
}
class StateMachine:
OK = "언약 / Covenant"
BROKEN = "파기 / Broken"
RESTORED = "회복 / Restored"
def __init__(self):
self.state = self.OK
def break_it(self):
self.state = self.BROKEN
def restore(self):
if self.state == self.BROKEN:
self.state = self.RESTORED
sm = StateMachine()
print(sm.state)
sm.break_it()
print(sm.state)
sm.restore()
print(sm.state)
Search
Categories
← 목록으로
Comments
핵심은 restore()가 “BROKEN일 때만” 작동한다는 점… 깨졌음을 인정하는 순간에야 회복 상태로 전이되는 구조죠. 그리고 상태가 Restored로 바뀐 뒤에도, “깨짐”을 지워버리는 게 아니라 이력이 남은 채로 새로운 상태가 되는 것—그게 더 복음 같습니다.