Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <sstream>
- using namespace std;
- using std::string;
- #include "movie.h"
- #include "rental.h"
- #include "customer.h"
- string Customer::get_statement()
- {
- ostringstream out_string;
- int frequentRenterPoints = 0;
- double totalAmount = 0;
- string result;
- string movieTitles;
- out_string << "Rental Record For " << get_name();
- double temptotal =0;
- for (unsigned i=0; i < _rentals.size(); i++)
- {
- temptotal=0;
- if(_rentals[i].get_movie().get_price_code()==0)
- {
- if(_rentals[i].get_days_rented()<=2)
- {
- temptotal=temptotal+2;
- }
- else
- {
- temptotal=temptotal+2 +((_rentals[i].get_days_rented()-2)*1.5);
- }
- }
- else if(_rentals[i].get_movie().get_price_code()==1)
- {
- temptotal=temptotal+ (_rentals[i].get_days_rented()*3);
- }
- else if(_rentals[i].get_movie().get_price_code()==2)
- {
- if(_rentals[i].get_days_rented()<=3)
- {
- temptotal=temptotal+1.5;
- }
- else
- {
- temptotal=temptotal+1.5 +((_rentals[i].get_days_rented()-3)*1.5);
- }
- }
- out_string<<"\n"<< _rentals[i].get_movie().get_title() << " " ;
- //cout<<title<<" "<<temptotal<<endl;
- out_string<<temptotal;
- totalAmount=totalAmount+temptotal;
- }
- out_string<< "\nAmount owed is " << totalAmount << "\nYou earned " << frequentRenterPoints << " frequent renter points";
- return out_string.str();
- }
- int main()
- {
- Customer *cust = new Customer("Liam Neeson");
- Movie m1("Schindler's List", Movie::REGULAR);
- Movie m2("Fiber in the diet", Movie::REGULAR);
- Rental r1(m1, 2);
- Rental r2(m2, 1);
- cust->add_rental(r1);
- cust->add_rental(r2);
- std::cout << cust->get_statement(); // Print out the statement
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement