단계체인

2026년 2월 3일 13:23분

package com.jesusbornd.exodus;

public class Exodus_25_Chapter_Lv2 {

    interface BuilderStep {
        String name();
        BuilderStep next();
    }

    static class ArkStep implements BuilderStep {
        public String name() { return "언약궤 / Ark"; }
        public BuilderStep next() { return new TableStep(); }
    }

    static class TableStep implements BuilderStep {
        public String name() { return "진설병 상 / Table"; }
        public BuilderStep next() { return new LampstandStep(); }
    }

    static class LampstandStep implements BuilderStep {
        public String name() { return "등대 / Lampstand"; }
        public BuilderStep next() { return null; }
    }

    static void run(BuilderStep step) {
        BuilderStep cur = step;
        while (cur != null) {
            System.out.println(cur.name());
            cur = cur.next();
        }
    }

    public static void main(String[] args) {
        run(new ArkStep());
    }
}

from dataclasses import dataclass
from typing import Optional

class Step:
    def name(self) -> str:
        raise NotImplementedError

    def next(self):
        raise NotImplementedError

@dataclass(frozen=True)
class ArkStep(Step):
    def name(self) -> str:
        return "언약궤 / Ark"
    def next(self):
        return TableStep()

@dataclass(frozen=True)
class TableStep(Step):
    def name(self) -> str:
        return "진설병 상 / Table"
    def next(self):
        return LampstandStep()

@dataclass(frozen=True)
class LampstandStep(Step):
    def name(self) -> str:
        return "등대 / Lampstand"
    def next(self):
        return None

def run(step: Step):
    cur: Optional[Step] = step
    while cur is not None:
        print(cur.name())
        cur = cur.next()

run(ArkStep())

Comments

Avatar
 2026년 2월 3일 13:25분

본문 구조 그대로: 언약궤 → 상 → 등대가 출 25장의 흐름과 맞아떨어져서, 코드 자체가 “본문 요약”이 된다.



Search

← 목록으로