/* This file contains the definition of the functions for SalesTable.

--------------------------------------------------------------------*/

#include "SalesTable.h"

/*-------------------------------------------------------------------
 This function displays a SalesTable as a report, including row
   and column labels, plus row and column summaries.

   Receive: An ostream (default value cout)
   Output:  The SalesTable containing this function, with row
               and column labels, and row and columns summaries
-------------------------------------------------------------------*/

#include <iomanip.h>

void SalesTable::DisplayReport(ostream& Out) const
{
  const int
     Width = 5;

  Out << setprecision(0);                         // integer display

  Out << "\n                          Salesperson\n";
  Out << " Models :    1    2    3    4    5    6    "
      << "7    8   : Totals\n";
  Out << "--------------------------------------------"
      << "----------------\n";

  for (int row = 0; row < Rows_; row++)
  {
     Out << setw(Width) << (row + 1) << "   : ";

     for (int col = 0; col < Columns_; col++)
        Out << setw(Width) << Grid[row][col];

     Out << "   :" << setw(Width) << RowSum(row) << endl;
  }

  Out << "---------------------------------------"
      << "-----------------------\n";
  Out << " Totals : ";
  for (int col = 0; col < Columns_; col++)
     Out << setw(Width) << ColumnSum(col);
  Out << "\n\n";
}

