16 lines
383 B
C++
16 lines
383 B
C++
#include "sale.h"
|
|
|
|
#include <numeric>
|
|
|
|
void Sale::addArticle(std::shared_ptr<Article> articlePtr)
|
|
{
|
|
articlePtr->setSale(this);
|
|
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;
|
|
} |