stats.cpp 403 Bytes
Newer Older
1
#include "stats.h"
2
#include "tools.h"
3 4 5 6

Stats::Stats()
{
  nb = 0 ;
7
  data = 0 ;
8 9 10 11 12 13 14
}

void Stats::setLabel(string _label)
{
  label = _label ;
}

15
void Stats::insert(int _data)
16 17
{
  nb++ ;
18
  data += _data ;
19 20
}

21
float Stats::getAverage()
22
{
23
  return (float) data / nb ;
24 25 26 27
}

ostream &operator<<(ostream &out, Stats &stats)
{
28
  output_label_average(out, stats.label, stats.nb, stats.getAverage());
29 30
  return out;
}