Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include "PetDB.h"
  2.  
  3. #include <iostream>
  4. #include <string>
  5. #include <fstream>
  6.  
  7.  
  8. int main()
  9. {
  10. PetDB db;
  11. db.loadFromFile("test.txt");
  12. std::ofstream out("out.txt");
  13.  
  14. {
  15. std::cout << "Data Base: pets" << "\n";
  16. for (size_t i = 0; i < db.count(); i++)
  17. {
  18. std::cout << i + 1 << ":";
  19. auto data = db.getRow(i);
  20.  
  21. for (const auto& str : data)
  22. std::cout << " " << str;
  23.  
  24. std::cout << "\n\n";
  25. }
  26. }
  27.  
  28. {
  29. auto owners = db.getOwnerList();
  30. for (const auto& owner : owners)
  31. {
  32. auto [ownerID, ownerName] = owner;
  33.  
  34. std::cout << ownerID << " : " << ownerName << "\n";
  35. auto pets = db.getOwnerPetCounts(owner.first);
  36.  
  37. for (const auto& pet : pets) {
  38. auto [type, count] = pet;
  39. std::cout << "\t" << Pet::typeStr(type) << " : " << count << "\n";
  40. }
  41. }
  42.  
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement