Advertisement
huutho_96

IT002.F24.2

May 19th, 2015
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.11 KB | None | 0 0
  1. //https://www.facebook.com/pages/C%C3%B9ng-h%E1%BB%8Dc-l%E1%BA%ADp-tr%C3%ACnh/632038696941833
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5. class SanBong
  6. {
  7. protected:
  8. string MaSB, TenSB, ThanhPho;
  9. public:
  10. SanBong(string MaSB = "", string TenSB = "", string ThanhPho = "")
  11. {
  12. this->MaSB = MaSB;
  13. this->TenSB = TenSB;
  14. this->ThanhPho = ThanhPho;
  15. }
  16. ~SanBong(){ };
  17. friend ostream& operator << (ostream& out, SanBong S)
  18. {
  19. out << "Ma san bong: " << S.MaSB << endl << "Ten san bong: " << S.TenSB << endl << "Ten thanh pho: " << S.ThanhPho << endl;
  20. return out;
  21. }
  22. friend istream& operator >> (istream& in, SanBong &S)
  23. {
  24. fflush(stdin);
  25. cout << "Nhap ma san bong: ";
  26. getline(in, S.MaSB);
  27. cout << "Nhap ten san bong: ";
  28. getline(in, S.TenSB);
  29. cout << "Nhap ten thanh pho: ";
  30. getline(in, S.ThanhPho);
  31. return in;
  32. }
  33. void operator = (SanBong S)
  34. {
  35. this->MaSB = S.MaSB;
  36. this->TenSB = S.TenSB;
  37. this->ThanhPho = S.ThanhPho;
  38. }
  39.  
  40. };
  41.  
  42. class DSSanBong
  43. {
  44. protected:
  45. int SoSanBong;
  46. SanBong *S;
  47. public:
  48. DSSanBong(int n = 0)
  49. {
  50. S = NULL;
  51. this->SoSanBong = n;
  52. while (this->SoSanBong < 0)
  53. {
  54. cout << "Nhap lai so doi bong = ";
  55. cin >> this->SoSanBong;
  56. }
  57. S = new SanBong[n];
  58. }
  59. ~DSSanBong()
  60. {
  61. delete[] S;
  62. }
  63. DSSanBong(const DSSanBong& D)
  64. {
  65. this->SoSanBong = D.SoSanBong;
  66. this->S = new SanBong[D.SoSanBong];
  67. for (int i = 0; i < this->SoSanBong; i++)
  68. this->S[i] = D.S[i];
  69. }
  70. friend ostream& operator << (ostream& out, DSSanBong D)
  71. {
  72. for (int i = 0; i < D.SoSanBong; i++)
  73. {
  74. out << "San bong thu: " << i + 1 << endl;
  75. out << D.S[i];
  76. }
  77. return out;
  78. }
  79. friend istream& operator >> (istream& in, DSSanBong &D)
  80. {
  81. system("cls");
  82. for (int i = 0; i < D.SoSanBong; i++)
  83. {
  84. cout << "Nhap san bong thu: " << i + 1 << endl;
  85. in >> D.S[i];
  86. }
  87. return in;
  88. }
  89. //them vao cuoi
  90. DSSanBong& operator ++()
  91. {
  92. this->SoSanBong++;
  93. DSSanBong D(this->SoSanBong);
  94. for (int i = 0; i < this->SoSanBong - 1; i++)
  95. D.S[i] = this->S[i];
  96. delete[] this->S;
  97. this->S = D.S;
  98. D.S = NULL;
  99. cin >> this->S[this->SoSanBong - 1];
  100. return *this;
  101. }
  102. //them vao dau
  103. DSSanBong operator ++(int)
  104. {
  105. this->SoSanBong++;
  106. DSSanBong D(this->SoSanBong);
  107. for (int i = this->SoSanBong - 1; i > 0; i--)
  108. D.S[i] = this->S[i - 1];
  109. delete[] this->S;
  110. this->S = D.S;
  111. D.S = NULL;
  112. cin >> this->S[0];
  113. return *this;
  114. }
  115. //bot phan tu cuoi
  116. DSSanBong& operator --()
  117. {
  118. this->SoSanBong--;
  119. DSSanBong D(this->SoSanBong);
  120. for (int i = 0; i < this->SoSanBong; i++)
  121. D.S[i] = this->S[i];
  122. delete[] this->S;
  123. this->S = D.S;
  124. D.S = NULL;
  125. return *this;
  126. }
  127. //bot phan tu dau
  128. DSSanBong operator --(int)
  129. {
  130. this->SoSanBong--;
  131. DSSanBong D(this->SoSanBong);
  132. for (int i = 0; i < this->SoSanBong; i++)
  133. D.S[i] = this->S[i + 1];
  134. delete[] this->S;
  135. this->S = D.S;
  136. D.S = NULL;
  137. return *this;
  138. }
  139. };
  140.  
  141. class LoaiCauThu
  142. {
  143. protected:
  144. string Ten, MaLoaiCauThu;
  145. public:
  146. LoaiCauThu(string Ten = "", string Ma = "")
  147. {
  148. if (Ma == "NN" || Ma == "ND" || Ten == "")
  149. {
  150. if (Ma == "NN") Ma += "\tNuoc Ngoai";
  151. else Ma += "\tNoi Dia";
  152. this->MaLoaiCauThu = Ma;
  153. this->Ten = Ten;
  154. }
  155. else
  156. {
  157. cout << "Khoi tao loi. Ma khong hop le";
  158. }
  159. }
  160. ~LoaiCauThu(){};
  161. friend istream& operator >>(istream& in, LoaiCauThu &C)
  162. {
  163. fflush(stdin);
  164. cout << "Nhap Ten: ";
  165. getline(in, C.Ten);
  166. do
  167. {
  168. cout << "\nDanh sach loai cau thu\nND Noi dia\nNN Nuoc ngoai\n";
  169. cout << "Nhap loai cau thu: ";
  170. getline(in, C.MaLoaiCauThu);
  171. cout << endl;
  172. if (C.MaLoaiCauThu.compare("ND") == 0 || C.MaLoaiCauThu.compare("NN") == 0)
  173. {
  174. if (C.MaLoaiCauThu == "ND") C.MaLoaiCauThu += "\tNoiDia";
  175. else C.MaLoaiCauThu += "\tNuoc Ngoai";
  176. break;
  177. }
  178. } while (1);
  179. return in;
  180. }
  181. friend ostream& operator <<(ostream& out, LoaiCauThu C)
  182. {
  183. out << "Ten Cau Thu: " << C.Ten << endl;
  184. out << "Loai Cau Thu: " << C.MaLoaiCauThu << endl;
  185. return out;
  186. }
  187. };
  188.  
  189. class HLV
  190. {
  191. protected:
  192. string NgaySinh, Ten, Ma;
  193. private:
  194. string ChucVu, GioiTinh;
  195. public:
  196. HLV(string Ten = "", string Ma = "", string NgaySinh = "", string ChucVu = "", bool GioiTinh = 0)
  197. {
  198. this->Ten = Ten;
  199. this->Ma = Ma;
  200. this->GioiTinh = GioiTinh;
  201. this->ChucVu = ChucVu;
  202. this->NgaySinh = NgaySinh;
  203. }
  204. ~HLV(){};
  205. friend istream& operator >>(istream& in, HLV &H)
  206. {
  207. fflush(stdin);
  208. cout << "Nhap Ten: ";
  209. getline(in, H.Ten);
  210. cout << "Nhap Ma: ";
  211. getline(in, H.Ma);
  212. cout << "Ngay Sinh: ";
  213. getline(in, H.NgaySinh);
  214. cout << "Chuc Vu: ";
  215. getline(in, H.ChucVu);
  216. cout << "Gioi Tinh: ";
  217. getline(in, H.GioiTinh);
  218. return in;
  219. }
  220. friend ostream& operator <<(ostream& out, HLV H)
  221. {
  222. out << "Ten : " << H.Ten << endl << "Ma : " << H.Ma << endl;
  223. out << "Ngay Sinh: " << H.NgaySinh << endl;
  224. out << "Chuc Vu: " << H.ChucVu << endl;
  225. out << "Gioi Tinh: " << H.GioiTinh << endl;
  226. return out;
  227. }
  228. };
  229.  
  230. class CauThu : public LoaiCauThu
  231. {
  232. protected:
  233. string NgaySinh, MaCauThu, GhiChu;
  234. int SoAo;
  235. public:
  236. CauThu(string Ten = "", string MaCauThu = "", string NgaySinh = "", string MaLoaiCauThu = "", string GhiChu = "", int SoAo = 0) : LoaiCauThu(Ten, MaLoaiCauThu)
  237. {
  238. this->NgaySinh = NgaySinh;
  239. this->MaCauThu = MaCauThu;
  240. this->GhiChu = GhiChu;
  241. this->SoAo = SoAo;
  242. }
  243. ~CauThu(){};
  244. friend ostream& operator << (ostream& out, CauThu C)
  245. {
  246. LoaiCauThu *L = &C;
  247. out << *L;
  248. out << "Ngay Sinh: " << C.NgaySinh << endl << "Ma Cau Thu: " << C.MaCauThu << endl;
  249. out << "So Ao: " << C.SoAo << endl << "Ghi Chu: " << C.GhiChu << endl;
  250. return out;
  251. }
  252. friend istream& operator >> (istream& in, CauThu &C)
  253. {
  254. LoaiCauThu *L = &C;
  255. in >> *L;
  256. fflush(stdin);
  257. cout << "Ngay Sinh: ";
  258. getline(in, C.NgaySinh);
  259. cout << "Ma Cau Thu: ";
  260. getline(in, C.MaCauThu);
  261. cout << "So Ao: ";
  262. cin >> C.SoAo;
  263. cout << "Ghi Chu: ";
  264. getline(in, C.GhiChu);
  265. return in;
  266. }
  267. };
  268.  
  269. class DoiBong
  270. {
  271. protected:
  272. string TenDB, MaDB, MaSB;
  273. int SoHLV, SoCauThu, DiemSo;
  274. HLV *H;
  275. CauThu *C;
  276. public:
  277. void operator = (DoiBong D)
  278. {
  279. this->TenDB = D.TenDB;
  280. this->DiemSo = D.DiemSo;
  281. this->MaDB = D.MaDB;
  282. this->MaSB = D.MaSB;
  283. this->SoCauThu = D.SoCauThu;
  284. this->SoHLV = D.SoHLV;
  285. this->H = new HLV[this->SoHLV];
  286. this->C = new CauThu[this->SoCauThu];
  287. for (int i = 0; i < this->SoHLV; i++)
  288. this->H[i] = D.H[i];
  289. for (int i = 0; i < this->SoCauThu; i++)
  290. this->C[i] = D.C[i];
  291. }
  292. DoiBong(string Ten = "", string MaDB = "", string MaSB = "", int SoHLV = 0, int SoCauThu = 0)
  293. {
  294. this->TenDB = Ten;
  295. this->DiemSo = 0;
  296. this->MaDB = MaDB;
  297. this->MaSB = MaSB;
  298. this->SoHLV = SoHLV;
  299. this->SoCauThu = SoCauThu;
  300. }
  301. bool operator == (DoiBong D)
  302. {
  303. return (this->DiemSo == D.DiemSo);
  304. }
  305. friend istream& operator >> (istream& in, DoiBong &D)
  306. {
  307.  
  308. }
  309.  
  310.  
  311. };
  312. void main()
  313. {
  314. //DSSanBong D(1);
  315. //cin >> D;
  316. //D++;//them vao dau
  317. //++D;//them vao cuoi
  318. //D--;
  319. //--D;
  320. //cout << D;
  321. //CauThu C;
  322. //cin >> C;
  323. //cout << C;
  324. DoiBong a("1", "1", "1", 1, 1);
  325. DoiBong b("1", "1", "1", 1, 1);
  326. cout << (a == b);
  327. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement