트랜잭션
2026년 3월 24일 09:30분
package com.jesusbornd.leviticus;
public class Leviticus_16_Chapter_Lv2 {
public static class DayOfAtonementTx {
private boolean bathed = false;
private boolean clothed = false;
private boolean bloodApplied = false;
public void bathe() {
bathed = true;
}
public void clothe() {
if (!bathed) throw new IllegalStateException("bathe first");
clothed = true;
}
public void applyBlood() {
if (!clothed) throw new IllegalStateException("clothe first");
bloodApplied = true;
}
public void commit() {
if (!(bathed && clothed && bloodApplied)) throw new IllegalStateException("incomplete");
System.out.println("속죄 완료 / Atonement complete");
}
}
public static void main(String[] args) {
DayOfAtonementTx tx = new DayOfAtonementTx();
tx.bathe();
tx.clothe();
tx.applyBlood();
tx.commit();
}
}
class DayOfAtonementTx:
def __init__(self):
self.bathed = False
self.clothed = False
self.blood_applied = False
def bathe(self):
self.bathed = True
def clothe(self):
if not self.bathed:
raise RuntimeError("bathe first")
self.clothed = True
def apply_blood(self):
if not self.clothed:
raise RuntimeError("clothe first")
self.blood_applied = True
def commit(self):
if not (self.bathed and self.clothed and self.blood_applied):
raise RuntimeError("incomplete")
print("속죄 완료 / Atonement complete")
tx = DayOfAtonementTx()
tx.bathe()
tx.clothe()
tx.apply_blood()
tx.commit()
Search
Categories
← 목록으로
Comments
마지막 commit()에서 모든 조건이 충족되어야 “속죄 완료”가 선언되는 흐름이 분명하게 느껴집니다.