package com.bookshop.solid.lsp;

import java.math.BigDecimal;
import java.util.List;

/**
 * Relies on the {@link Purchasable} contract and nothing else -- no
 * {@code instanceof} checks, no defensive try/catch around "weird" subtypes.
 */
public final class Till {

    private Till() {
    }

    public static BigDecimal totalOf(List<Purchasable> basket) {
        return basket.stream().map(Purchasable::price).reduce(BigDecimal.ZERO, BigDecimal::add);
    }
}
