사례목록

2026년 1월 29일 17:51분

package com.jesusbornd.exodus;

import java.util.ArrayList;
import java.util.List;

public class Exodus_22_Chapter_Lv2 {

    static class CaseResult {
        final String caseName;
        final boolean responsible;
        final String action;

        CaseResult(String caseName, boolean responsible, String action) {
            this.caseName = caseName;
            this.responsible = responsible;
            this.action = action;
        }

        String render() {
            return caseName + " => " + (responsible ? action : "면제 / No liability");
        }
    }

    static List<String> evaluate(List<CaseResult> cases) {
        List<String> out = new ArrayList<>();
        for (CaseResult c : cases) out.add(c.render());
        return out;
    }

    public static void main(String[] args) {
        List<CaseResult> cases = List.of(
                new CaseResult("도둑질 / Theft", true, "배상 / Restitution"),
                new CaseResult("분실 / Loss", true, "보상 / Compensation"),
                new CaseResult("우발 / Accident", false, "해당 없음 / N/A")
        );

        for (String line : evaluate(cases)) {
            System.out.println(line);
        }
    }
}

from dataclasses import dataclass

@dataclass(frozen=True)
class CaseResult:
    case_name: str
    responsible: bool
    action: str

    def render(self) -> str:
        return f"{self.case_name} => {self.action if self.responsible else '면제 / No liability'}"

def evaluate(cases):
    return [c.render() for c in cases]

cases = [
    CaseResult("도둑질 / Theft", True, "배상 / Restitution"),
    CaseResult("분실 / Loss", True, "보상 / Compensation"),
    CaseResult("우발 / Accident", False, "해당 없음 / N/A"),
]

for line in evaluate(cases):
    print(line)

Comments

Avatar
 2026년 1월 29일 17:55분

render() 한 줄이 판사 망치 소리 같아요. “유죄: 배상 / 무죄: 면제” 깔끔!



Search

← 목록으로