package com.bookshop.solid.isp;

import com.bookshop.domain.Book;
import com.bookshop.domain.Customer;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/** The full-timer genuinely does all three jobs, so implements all three roles. */
public class ShopManager implements Bookseller, StockManager, Accountant {

    private final Map<String, Integer> shelf = new HashMap<>();
    private BigDecimal takings = BigDecimal.ZERO;

    @Override
    public String sell(Book book, Customer customer) {
        takings = takings.add(book.price());
        return "sold " + book.title() + " to " + customer.name();
    }

    @Override
    public void restock(Book book, int copies) {
        shelf.merge(book.isbn(), copies, Integer::sum);
    }

    @Override
    public BigDecimal dailyTakings() {
        return takings;
    }
}
