Advertisement
Khillz3000

CD.h

May 11th, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. //Class CD Header File
  2. //
  3. #ifndef CD_H
  4. #define CD_H
  5. #include "stdafx.h"
  6. #include "LinkList.h"
  7. #include "Media.h"
  8. #include <iostream>
  9. #include <iomanip>
  10. #include <string>
  11.  
  12. using namespace std;
  13. //LinkList structure for CD class
  14.  
  15. struct CdContence
  16. {
  17. string song;
  18. string length;
  19. };
  20.  
  21.  
  22.  
  23. class CD : public Media
  24. {
  25. public:
  26.  
  27. LinkList<CdContence> Cd;
  28.  
  29. public:
  30.  
  31. //***Constructors***
  32. CD(string, string);
  33. CD();
  34. CD(const CD &obj);
  35. CD operator = (const CD &);
  36.  
  37. //***destructor***
  38. ~CD();
  39.  
  40. //***Mutators***
  41. void setCD(string, string, string, string);
  42.  
  43. //***Accessors***
  44. LinkList<CdContence> getCD();
  45.  
  46.  
  47. //Overloaded Operators
  48.  
  49. bool operator < (CD &);
  50. bool operator > (CD &);
  51. bool operator != (CD &);
  52. bool operator == (CD &);
  53. };
  54.  
  55. /*****Implimentation*********/
  56. //***Constructors***
  57.  
  58. CD::CD(string T, string L) : Media(T, L)
  59. {
  60. cout<<"CD CONSTRUCTOR2"<<endl;
  61. }
  62.  
  63. CD::CD() : Media()
  64. {
  65. cout<<"CD CONSTRUCTOR"<<endl;
  66. }
  67.  
  68. //CD::CD(const CD &obj) :Media(obj)
  69. //{
  70. //
  71. // Cd = obj.Cd;
  72. //
  73. //}
  74.  
  75. CD::CD(const CD &obj)
  76.  
  77. :Media(obj),
  78.  
  79. Cd(obj.Cd)
  80.  
  81. {}
  82.  
  83.  
  84. //****=Destructor***
  85. CD::~CD()
  86. {
  87. cout<<"CD destructor"<<endl;
  88. }
  89.  
  90. //***Mutators***
  91. void CD::setCD (string T, string L,string s, string l)
  92. {
  93. setTitle(T);
  94. setLength(L);
  95. CdContence temp;
  96. temp.song = s;
  97. temp.length = l;
  98.  
  99. Cd.appendNode(temp);
  100. }
  101.  
  102.  
  103. //***Accessors***
  104. LinkList<CdContence> CD::getCD()
  105. {
  106. return Cd;
  107. }
  108.  
  109.  
  110. //***Overloaded operators***
  111.  
  112. CD CD::operator = (const CD &obj)
  113. {
  114. Media::operator=(obj);
  115.  
  116. Cd = obj.Cd;
  117.  
  118. cout<<" CD Assignment operator called "<<endl;
  119. return *this;
  120. }
  121.  
  122. bool CD::operator < (CD &right)
  123. {
  124. bool status;
  125.  
  126. if (getTitle() < right.getTitle())
  127. status = true;
  128.  
  129. else
  130. status = false;
  131.  
  132. return status;
  133. }
  134.  
  135. bool CD::operator > (CD &right)
  136. {
  137. bool status;
  138.  
  139. if (getTitle() > right.getTitle())
  140. status = true;
  141. else
  142. status = false;
  143.  
  144. return status;
  145. }
  146.  
  147. bool CD::operator != (CD &right)
  148. {
  149. bool status;
  150.  
  151. if (*this == right)
  152. status = false;
  153. else
  154. status = true;
  155.  
  156. return status;
  157. }
  158.  
  159. bool CD::operator == (CD &right)
  160. {
  161. bool status;
  162.  
  163. if (getTitle() == right.getTitle())
  164. status = true;
  165.  
  166. else
  167. status = false;
  168.  
  169. return status;
  170. }
  171.  
  172.  
  173. ostream &operator<<(ostream &strm, CD &obj)
  174. {
  175. strm
  176. <<"CD Title: "<< obj.getTitle() << "\n"
  177. <<"CD Length: "<< obj.getLength()<< "\n"
  178. <<endl;
  179.  
  180. return strm;
  181. obj.Cd.displayList();
  182.  
  183. }
  184. ostream &operator<<(ostream &strm, CdContence &obj)
  185. {
  186. strm
  187. <<"Song Title: "<< obj.song << "\n"
  188. <<"Song Length: "<< obj.length << "\n"
  189. <<endl;
  190.  
  191. return strm;
  192. }
  193. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement