kima2/src/core/sale.cpp

15 lines
352 B
C++
Raw Normal View History

2018-07-12 13:34:17 +02:00
#include "sale.h"
#include <numeric>
2018-07-12 13:42:22 +02:00
void Sale::addArticle(std::shared_ptr<Article> articlePtr)
{
articles_.push_back(articlePtr);
}
2018-07-12 13:34:17 +02:00
int Sale::sumInCents()
{
2018-07-12 13:42:22 +02:00
int sum = std::accumulate(articles_.begin(), articles_.end(), 0,
[](int a, std::shared_ptr<Article> b) { return a + b->getPrice(); });
return sum;
2018-07-12 13:34:17 +02:00
}