package com.example.backend.core.session;

import java.util.HashMap;

import com.example.backend.orders.api.BookCountDto;

public class SessionCart extends HashMap<Long, BookCountDto> {
    public int getCount() {
        return this.size();
    }

    public double getSum() {
        return this.values().stream()
                .map(item -> item.getCount() * item.getBook().getPrice())
                .mapToDouble(Double::doubleValue)
                .sum();
    }
}
