15 lines
352 B
C++
15 lines
352 B
C++
#include "sale.h"
|
|
|
|
#include <numeric>
|
|
|
|
void Sale::addArticle(std::shared_ptr<Article> articlePtr)
|
|
{
|
|
articles_.push_back(articlePtr);
|
|
}
|
|
|
|
int Sale::sumInCents()
|
|
{
|
|
int sum = std::accumulate(articles_.begin(), articles_.end(), 0,
|
|
[](int a, std::shared_ptr<Article> b) { return a + b->getPrice(); });
|
|
return sum;
|
|
} |