Facebook
From bmys, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 284
  1. //
  2. // Created by arch on 27.10.17.
  3. //
  4. #include "Rent.h"
  5.  
  6.  
  7.  
  8.    Rent::Rent(const lt::local_date_time &startRentData, Vehicle *vehicle, Client *client) :
  9.             startRentData(startRentData),
  10.             vehicle(vehicle),
  11.             client(client),
  12.             stopRentData(startRentData)
  13.         {
  14.  
  15.        std:: cout  <<"\n" << this->startRentData<<"\n";
  16.  
  17.        boost::uuids::uuid uuid = boost::uuids::random_generator()();
  18.        this->uniqId =boost::lexical_cast<std::string>(uuid);
  19.        this->price = vehicle->getrentPrice();
  20.  
  21.        //std::cout<<this->uniqId<< std::endl;
  22.    }
  23.  
  24. std:: string Rent::rentInfo(){
  25.     return this->uniqId + " Samochod: " + vehicle->vehicleInfo() + "\n";
  26. }
  27.  
  28. namespace lt = boost::local_time;
  29. namespace pt = boost::posix_time;
  30.  
  31. float Rent::stopRent(lt::local_date_time ldt){
  32.  
  33.     std::cout << ldt << std::endl;
  34.     std::cout << "Roznica czasu:"<< std::endl;
  35.     this->stopRentData = ldt;
  36.     std::cout << this-> stopRentData;
  37.  
  38.     pt::time_duration dur = ldt - this->startRentData;
  39.     int seconds = dur.total_seconds();
  40.  
  41.     int days = seconds / 86400;
  42.     if((seconds % 86400)>0){
  43.         days++;
  44.     }
  45.     this->rentDays = days;
  46.     this->rentCost = days * this->price;
  47.  
  48.     std::cout <<days<<std::endl;
  49.     std::cout <<this->rentCost<<std::endl;
  50.  
  51.  
  52.  
  53.  
  54. return 0;
  55. }
  56.