/**
 * @file stats.cpp
 * @author Jan Holáň, xholan11 (xholan11@vutbr.cz)
 * @brief translated with gcc version 12.2.1
 * @version 0.1
 * @date 2023-05-01
 * 
 * @copyright Copyright (c) 2023
 * 
 */

#include "stats.h"

using namespace std;

string stats::eachCartStats(list<Cart> cart_list)
{
    string result = "";
    // print header
    result += "CART_NUMBER      TOTAL_CUSTOMERS     TOTAL_ITEMS     FULL_BOXES      ONE_BOXES       DISTANCE(dm)\n";
    int cart_num = 0;
    for (auto cart : cart_list)
    {
        // CART NUMBER
        result.append(to_string(++cart_num) + "\t\t\t\t\t\t");
        // TOTAL CUSTOMERS
        result.append(to_string(cart.getCustomerVector().size()) + "\t\t\t\t");
        // TOTAL ITEMS
        result.append(to_string(cart.getItemVector().size()) + "\t\t\t\t");

        int full = 0, one = 0;
        for (auto shelf : cart.getCartShelvesVector())
        {
            full += shelf.getBoxes()->full_box_vect.size();
            one += shelf.getBoxes()->one_item_box_vect.size();
        }
        // TOTAL FULL BOXES
        result.append(to_string(full) + "\t\t\t\t");
        // TOTAL ONE BOXES
        result.append(to_string(one) + "\t\t\t\t");

        // DISTANCE
        result.append(to_string(cart.getEstimatedWalkedDistance()));
        // end line for the current customer
        result.append("\n");
    }

    return result;
}
