drone.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. using namespace std;
  10. drone::drone() {}
  11. drone::drone(int payload) {
  12. payload = payload;
  13. }
  14. void drone::self_destruct(bool explosives) {
  15. std::cout << "Self destruct timer initiated";
  16. }
  17. void drone::set_location(float longitude, float latitude) {
  18. std::cout << "Location set to " << longitude << std::endl << "Latitude set to " << latitude << std::endl;
  19. }
  20. int drone::explore(int explore_time) {
  21. int xRan;
  22. int distance_travelled;
  23. srand( time(0)); // This will ensure a really randomized number by help of time.
  24. xRan=rand()%9+1;
  25. distance_travelled = explore_time * xRan;
  26. return distance_travelled;
  27. // std::time_t startTime = std::time(nullptr);
  28. //
  29. // std::time_t currentTime;
  30. // double seconds;
  31. //
  32. // std::cout << "Input explore duration for drone mission: " << std::endl;
  33. // std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
  34. // std::time(&currentTime); //get the time now that the user has entered something and stick it in currentTime
  35. //
  36. // seconds = std::difftime(currentTime, startTime);
  37. // std::cout << "It took you " << seconds << " seconds to enter something.\n";
  38. //
  39. // std::cout << "Input something else...";
  40. // std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
  41. // std::time(&currentTime);
  42. //
  43. // seconds = std::difftime(currentTime, startTime);
  44. // std::cout << "It has now been " << seconds << " since you were asked to input something\n";
  45. return 69;
  46. }