Advertisement
Guest User

Untitled

a guest
May 29th, 2015
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4. using namespace std;
  5. using std::string;
  6.  
  7. #include "movie.h"
  8. #include "rental.h"
  9. #include "customer.h"
  10.  
  11. string Customer::get_statement()
  12. {
  13. ostringstream out_string;
  14. int frequentRenterPoints = 0;
  15. double totalAmount = 0;
  16. string result;
  17. string movieTitles;
  18. out_string << "Rental Record For " << get_name();
  19. double temptotal =0;
  20. for (unsigned i=0; i < _rentals.size(); i++)
  21. {
  22. temptotal=0;
  23.  
  24. if(_rentals[i].get_movie().get_price_code()==0)
  25. {
  26. if(_rentals[i].get_days_rented()<=2)
  27. {
  28. temptotal=temptotal+2;
  29. }
  30. else
  31. {
  32. temptotal=temptotal+2 +((_rentals[i].get_days_rented()-2)*1.5);
  33. }
  34. }
  35. else if(_rentals[i].get_movie().get_price_code()==1)
  36. {
  37. temptotal=temptotal+ (_rentals[i].get_days_rented()*3);
  38. }
  39. else if(_rentals[i].get_movie().get_price_code()==2)
  40. {
  41. if(_rentals[i].get_days_rented()<=3)
  42. {
  43. temptotal=temptotal+1.5;
  44. }
  45. else
  46. {
  47. temptotal=temptotal+1.5 +((_rentals[i].get_days_rented()-3)*1.5);
  48. }
  49. }
  50. out_string<<"\n"<< _rentals[i].get_movie().get_title() << " " ;
  51. //cout<<title<<" "<<temptotal<<endl;
  52. out_string<<temptotal;
  53. totalAmount=totalAmount+temptotal;
  54. }
  55.  
  56. out_string<< "\nAmount owed is " << totalAmount << "\nYou earned " << frequentRenterPoints << " frequent renter points";
  57. return out_string.str();
  58.  
  59.  
  60. }
  61.  
  62. int main()
  63. {
  64. Customer *cust = new Customer("Liam Neeson");
  65.  
  66. Movie m1("Schindler's List", Movie::REGULAR);
  67. Movie m2("Fiber in the diet", Movie::REGULAR);
  68.  
  69. Rental r1(m1, 2);
  70. Rental r2(m2, 1);
  71. cust->add_rental(r1);
  72. cust->add_rental(r2);
  73.  
  74. std::cout << cust->get_statement(); // Print out the statement
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement