절기관리
2026년 4월 2일 09:30분
레위기 23장은 여호와의 절기 목록입니다. 각 절기에는 날짜와 의식이 정해져 있습니다. 나는 절기를 이벤트 객체로 만들고 월별 캘린더에 등록했습니다. 날짜를 조회하면 해당 절기 정보가 반환됩니다.
package com.jesusbornd.leviticus;
import java.util.*;
public class Leviticus_23_Chapter_Lv3 {
enum Month { NISAN, SIVAN, TISHRI }
record Feast(String name, int day, String memo) {}
static class FeastCalendar {
private final Map<Month, List<Feast>> calendar = new HashMap<>();
FeastCalendar add(Month month, Feast feast) {
calendar.computeIfAbsent(month, k -> new ArrayList<>()).add(feast);
return this;
}
void lookup(Month month, int day) {
List<Feast> feasts = calendar.getOrDefault(month, List.of());
feasts.stream()
.filter(f -> f.day() == day)
.findFirst()
.ifPresentOrElse(
f -> System.out.println(month + " " + day + "일 → " + f.name() + " (" + f.memo() + ")"),
() -> System.out.println(month + " " + day + "일 → 일반 날")
);
}
}
public static void main(String[] args) {
FeastCalendar cal = new FeastCalendar()
.add(Month.NISAN, new Feast("유월절", 14, "어린양 잡음"))
.add(Month.NISAN, new Feast("무교절", 15, "7일간 무교병"))
.add(Month.NISAN, new Feast("초실절", 16, "첫 보리 단 흔들기"))
.add(Month.SIVAN, new Feast("칠칠절", 6, "밀 수확 50일 후"))
.add(Month.TISHRI, new Feast("나팔절", 1, "나팔 소리"))
.add(Month.TISHRI, new Feast("대속죄일", 10, "대제사장 지성소 입장"))
.add(Month.TISHRI, new Feast("초막절", 15, "7일간 초막 거주"));
cal.lookup(Month.NISAN, 14);
cal.lookup(Month.TISHRI, 10);
cal.lookup(Month.TISHRI, 3);
}
}
from dataclasses import dataclass
from collections import defaultdict
from enum import Enum
class Month(Enum):
NISAN = "니산"
SIVAN = "시완"
TISHRI = "티스리"
@dataclass
class Feast:
name: str
day: int
memo: str
class FeastCalendar:
def __init__(self):
self._calendar: dict[Month, list[Feast]] = defaultdict(list)
def add(self, month: Month, feast: Feast) -> "FeastCalendar":
self._calendar[month].append(feast)
return self
def lookup(self, month: Month, day: int):
match = next((f for f in self._calendar[month] if f.day == day), None)
if match:
print(f"{month.value} {day}일 → {match.name} ({match.memo})")
else:
print(f"{month.value} {day}일 → 일반 날")
if __name__ == "__main__":
cal = (
FeastCalendar()
.add(Month.NISAN, Feast("유월절", 14, "어린양 잡음"))
.add(Month.NISAN, Feast("무교절", 15, "7일간 무교병"))
.add(Month.NISAN, Feast("초실절", 16, "첫 보리 단 흔들기"))
.add(Month.SIVAN, Feast("칠칠절", 6, "밀 수확 50일 후"))
.add(Month.TISHRI, Feast("나팔절", 1, "나팔 소리"))
.add(Month.TISHRI, Feast("대속죄일", 10, "대제사장 지성소 입장"))
.add(Month.TISHRI, Feast("초막절", 15, "7일간 초막 거주"))
)
cal.lookup(Month.NISAN, 14)
cal.lookup(Month.TISHRI, 10)
cal.lookup(Month.TISHRI, 3)
Search
Categories
← 목록으로
Comments
절기마다 정해진 날짜와 의식을 이벤트 객체로 캘린더에 등록하는 방식이, 정해진 때를 지키는 의미를 잘 담고 있네요.