Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://www.facebook.com/pages/C%C3%B9ng-h%E1%BB%8Dc-l%E1%BA%ADp-tr%C3%ACnh/632038696941833
- #include <iostream>
- #include <string>
- using namespace std;
- class SanBong
- {
- protected:
- string MaSB, TenSB, ThanhPho;
- public:
- SanBong(string MaSB = "", string TenSB = "", string ThanhPho = "")
- {
- this->MaSB = MaSB;
- this->TenSB = TenSB;
- this->ThanhPho = ThanhPho;
- }
- ~SanBong(){ };
- friend ostream& operator << (ostream& out, SanBong S)
- {
- out << "Ma san bong: " << S.MaSB << endl << "Ten san bong: " << S.TenSB << endl << "Ten thanh pho: " << S.ThanhPho << endl;
- return out;
- }
- friend istream& operator >> (istream& in, SanBong &S)
- {
- fflush(stdin);
- cout << "Nhap ma san bong: ";
- getline(in, S.MaSB);
- cout << "Nhap ten san bong: ";
- getline(in, S.TenSB);
- cout << "Nhap ten thanh pho: ";
- getline(in, S.ThanhPho);
- return in;
- }
- void operator = (SanBong S)
- {
- this->MaSB = S.MaSB;
- this->TenSB = S.TenSB;
- this->ThanhPho = S.ThanhPho;
- }
- };
- class DSSanBong
- {
- protected:
- int SoSanBong;
- SanBong *S;
- public:
- DSSanBong(int n = 0)
- {
- S = NULL;
- this->SoSanBong = n;
- while (this->SoSanBong < 0)
- {
- cout << "Nhap lai so doi bong = ";
- cin >> this->SoSanBong;
- }
- S = new SanBong[n];
- }
- ~DSSanBong()
- {
- delete[] S;
- }
- DSSanBong(const DSSanBong& D)
- {
- this->SoSanBong = D.SoSanBong;
- this->S = new SanBong[D.SoSanBong];
- for (int i = 0; i < this->SoSanBong; i++)
- this->S[i] = D.S[i];
- }
- friend ostream& operator << (ostream& out, DSSanBong D)
- {
- for (int i = 0; i < D.SoSanBong; i++)
- {
- out << "San bong thu: " << i + 1 << endl;
- out << D.S[i];
- }
- return out;
- }
- friend istream& operator >> (istream& in, DSSanBong &D)
- {
- system("cls");
- for (int i = 0; i < D.SoSanBong; i++)
- {
- cout << "Nhap san bong thu: " << i + 1 << endl;
- in >> D.S[i];
- }
- return in;
- }
- //them vao cuoi
- DSSanBong& operator ++()
- {
- this->SoSanBong++;
- DSSanBong D(this->SoSanBong);
- for (int i = 0; i < this->SoSanBong - 1; i++)
- D.S[i] = this->S[i];
- delete[] this->S;
- this->S = D.S;
- D.S = NULL;
- cin >> this->S[this->SoSanBong - 1];
- return *this;
- }
- //them vao dau
- DSSanBong operator ++(int)
- {
- this->SoSanBong++;
- DSSanBong D(this->SoSanBong);
- for (int i = this->SoSanBong - 1; i > 0; i--)
- D.S[i] = this->S[i - 1];
- delete[] this->S;
- this->S = D.S;
- D.S = NULL;
- cin >> this->S[0];
- return *this;
- }
- //bot phan tu cuoi
- DSSanBong& operator --()
- {
- this->SoSanBong--;
- DSSanBong D(this->SoSanBong);
- for (int i = 0; i < this->SoSanBong; i++)
- D.S[i] = this->S[i];
- delete[] this->S;
- this->S = D.S;
- D.S = NULL;
- return *this;
- }
- //bot phan tu dau
- DSSanBong operator --(int)
- {
- this->SoSanBong--;
- DSSanBong D(this->SoSanBong);
- for (int i = 0; i < this->SoSanBong; i++)
- D.S[i] = this->S[i + 1];
- delete[] this->S;
- this->S = D.S;
- D.S = NULL;
- return *this;
- }
- };
- class LoaiCauThu
- {
- protected:
- string Ten, MaLoaiCauThu;
- public:
- LoaiCauThu(string Ten = "", string Ma = "")
- {
- if (Ma == "NN" || Ma == "ND" || Ten == "")
- {
- if (Ma == "NN") Ma += "\tNuoc Ngoai";
- else Ma += "\tNoi Dia";
- this->MaLoaiCauThu = Ma;
- this->Ten = Ten;
- }
- else
- {
- cout << "Khoi tao loi. Ma khong hop le";
- }
- }
- ~LoaiCauThu(){};
- friend istream& operator >>(istream& in, LoaiCauThu &C)
- {
- fflush(stdin);
- cout << "Nhap Ten: ";
- getline(in, C.Ten);
- do
- {
- cout << "\nDanh sach loai cau thu\nND Noi dia\nNN Nuoc ngoai\n";
- cout << "Nhap loai cau thu: ";
- getline(in, C.MaLoaiCauThu);
- cout << endl;
- if (C.MaLoaiCauThu.compare("ND") == 0 || C.MaLoaiCauThu.compare("NN") == 0)
- {
- if (C.MaLoaiCauThu == "ND") C.MaLoaiCauThu += "\tNoiDia";
- else C.MaLoaiCauThu += "\tNuoc Ngoai";
- break;
- }
- } while (1);
- return in;
- }
- friend ostream& operator <<(ostream& out, LoaiCauThu C)
- {
- out << "Ten Cau Thu: " << C.Ten << endl;
- out << "Loai Cau Thu: " << C.MaLoaiCauThu << endl;
- return out;
- }
- };
- class HLV
- {
- protected:
- string NgaySinh, Ten, Ma;
- private:
- string ChucVu, GioiTinh;
- public:
- HLV(string Ten = "", string Ma = "", string NgaySinh = "", string ChucVu = "", bool GioiTinh = 0)
- {
- this->Ten = Ten;
- this->Ma = Ma;
- this->GioiTinh = GioiTinh;
- this->ChucVu = ChucVu;
- this->NgaySinh = NgaySinh;
- }
- ~HLV(){};
- friend istream& operator >>(istream& in, HLV &H)
- {
- fflush(stdin);
- cout << "Nhap Ten: ";
- getline(in, H.Ten);
- cout << "Nhap Ma: ";
- getline(in, H.Ma);
- cout << "Ngay Sinh: ";
- getline(in, H.NgaySinh);
- cout << "Chuc Vu: ";
- getline(in, H.ChucVu);
- cout << "Gioi Tinh: ";
- getline(in, H.GioiTinh);
- return in;
- }
- friend ostream& operator <<(ostream& out, HLV H)
- {
- out << "Ten : " << H.Ten << endl << "Ma : " << H.Ma << endl;
- out << "Ngay Sinh: " << H.NgaySinh << endl;
- out << "Chuc Vu: " << H.ChucVu << endl;
- out << "Gioi Tinh: " << H.GioiTinh << endl;
- return out;
- }
- };
- class CauThu : public LoaiCauThu
- {
- protected:
- string NgaySinh, MaCauThu, GhiChu;
- int SoAo;
- public:
- CauThu(string Ten = "", string MaCauThu = "", string NgaySinh = "", string MaLoaiCauThu = "", string GhiChu = "", int SoAo = 0) : LoaiCauThu(Ten, MaLoaiCauThu)
- {
- this->NgaySinh = NgaySinh;
- this->MaCauThu = MaCauThu;
- this->GhiChu = GhiChu;
- this->SoAo = SoAo;
- }
- ~CauThu(){};
- friend ostream& operator << (ostream& out, CauThu C)
- {
- LoaiCauThu *L = &C;
- out << *L;
- out << "Ngay Sinh: " << C.NgaySinh << endl << "Ma Cau Thu: " << C.MaCauThu << endl;
- out << "So Ao: " << C.SoAo << endl << "Ghi Chu: " << C.GhiChu << endl;
- return out;
- }
- friend istream& operator >> (istream& in, CauThu &C)
- {
- LoaiCauThu *L = &C;
- in >> *L;
- fflush(stdin);
- cout << "Ngay Sinh: ";
- getline(in, C.NgaySinh);
- cout << "Ma Cau Thu: ";
- getline(in, C.MaCauThu);
- cout << "So Ao: ";
- cin >> C.SoAo;
- cout << "Ghi Chu: ";
- getline(in, C.GhiChu);
- return in;
- }
- };
- class DoiBong
- {
- protected:
- string TenDB, MaDB, MaSB;
- int SoHLV, SoCauThu, DiemSo;
- HLV *H;
- CauThu *C;
- public:
- void operator = (DoiBong D)
- {
- this->TenDB = D.TenDB;
- this->DiemSo = D.DiemSo;
- this->MaDB = D.MaDB;
- this->MaSB = D.MaSB;
- this->SoCauThu = D.SoCauThu;
- this->SoHLV = D.SoHLV;
- this->H = new HLV[this->SoHLV];
- this->C = new CauThu[this->SoCauThu];
- for (int i = 0; i < this->SoHLV; i++)
- this->H[i] = D.H[i];
- for (int i = 0; i < this->SoCauThu; i++)
- this->C[i] = D.C[i];
- }
- DoiBong(string Ten = "", string MaDB = "", string MaSB = "", int SoHLV = 0, int SoCauThu = 0)
- {
- this->TenDB = Ten;
- this->DiemSo = 0;
- this->MaDB = MaDB;
- this->MaSB = MaSB;
- this->SoHLV = SoHLV;
- this->SoCauThu = SoCauThu;
- }
- bool operator == (DoiBong D)
- {
- return (this->DiemSo == D.DiemSo);
- }
- friend istream& operator >> (istream& in, DoiBong &D)
- {
- }
- };
- void main()
- {
- //DSSanBong D(1);
- //cin >> D;
- //D++;//them vao dau
- //++D;//them vao cuoi
- //D--;
- //--D;
- //cout << D;
- //CauThu C;
- //cin >> C;
- //cout << C;
- DoiBong a("1", "1", "1", 1, 1);
- DoiBong b("1", "1", "1", 1, 1);
- cout << (a == b);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement