forked from GEN-B-Groupe-C/GEN_Labo_05
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bill.cpp
32 lines (26 loc) · 851 Bytes
/
Bill.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//
// Created by Pierre-Olivier on 21.06.2020.
//
#include "Bill.h"
using namespace std;
void Bill::addRental( const Rental& arg ) { _rentals.push_back( arg ); }
string Bill::statement()
{
double totalAmount = 0;
int frequentRenterPoints = 0;
ostringstream result;
result << "Rental Record for " << _customer.getName() << "\n";
for (auto& each: _rentals) {
// determine amounts for each line
totalAmount += each.getAmmount();
// add frequent renter points
frequentRenterPoints += each.getFrequentRenterPoint();
// show figures for this rental
result << each.getFigures();
}
// add footer lines
result << "Amount owed is " << totalAmount << "\n";
result << "You earned " << frequentRenterPoints
<< " frequent renter points";
return result.str();
}