Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #ifndef OLYMPIAN
  2. #define OLYMPIAN
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. #include "LListIter.h"
  7.  
  8. // A class for holding an Olympian
  9. // name and career medal total
  10. class Olympian {
  11. public:
  12.  
  13. // constructor
  14. Olympian(string nam= "", int T= 0, int G= 0 ) :
  15. name(nam), total(T), gold(G) {};
  16.  
  17. // get the name
  18. string getName() const { return name; }
  19. // get the total
  20. int getTotal() const { return total; }
  21. // get the number of golds
  22. int getGold() const { return gold; }
  23.  
  24. // set the name
  25. void setName(string nam) { name= nam; }
  26. // get the total
  27. void setTotal(int num) { total= num; }
  28. // get the number of golds
  29. void setGold(int num) { gold= num; }
  30.  
  31. // compare two Olympians by name (same name?)
  32. bool operator==(const Olympian &);
  33. // compare two Olympians by medal total (more medals?)
  34. bool operator>(const Olympian &);
  35.  
  36. private:
  37. string name;
  38. int total;
  39. int gold;
  40. };
  41.  
  42. // print out the name and the medal total
  43. ostream& operator<<(ostream &os, const Olympian &olist);
  44. Olympian iter(olist);
  45. if(!iter.end()) {
  46. do {
  47. os << " " << iter.getName();
  48. os << " " << iter.getTotal();
  49. os << " " << iter.getGold();
  50. }
  51. while(iter.next());
  52. }
  53. return os;
  54. }
  55. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement