package com.bookshop.behavioral.templatemethod;
import com.bookshop.domain.Book;
import java.math.BigDecimal;
/**
* HTML variant: different formatting, identical structure and totalling logic.
*
* <p>Deliberately simplified: real HTML output must escape {@code < > &} in field
* values -- use a templating library for that. The lesson here is the Template Method
* shape, not HTML generation.
*/
public class HtmlSalesReport extends SalesReport {
@Override
protected String header() {
return "<table><tr><th>Title</th><th>Price</th></tr>";
}
@Override
protected String line(Book sale) {
return "<tr><td>" + sale.title() + "</td><td>" + sale.price() + "</td></tr>";
}
@Override
protected String footer(BigDecimal total) {
return "<tr><td>Total</td><td>" + total + "</td></tr></table>";
}
}