drone.cpp 1018 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // Created by logicp on 4/22/17.
  3. //
  4. #include <stdio.h>
  5. #include <iostream>
  6. #include <ctime>
  7. #include <limits>
  8. #include "drone.h"
  9. drone::drone() {}
  10. drone::drone(int payload) {
  11. payload = payload;
  12. }
  13. int drone::explore() {
  14. std::time_t startTime = std::time(nullptr);
  15. std::time_t currentTime;
  16. int explore_time;
  17. double seconds;
  18. std::cout << "Input explore duration for drone mission: " << std::endl;
  19. std::cin >> explore_time;
  20. std::time(&currentTime); //get the time now that the user has entered something and stick it in currentTime
  21. seconds = std::difftime(currentTime, startTime);
  22. std::cout << "It took you " << seconds << " seconds to enter something.\n";
  23. std::cout << "Input something else...";
  24. std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
  25. std::time(&currentTime);
  26. seconds = std::difftime(currentTime, startTime);
  27. std::cout << "It has now been " << seconds << " seconds since you started the program.\n";
  28. return 69;
  29. }