Lập trình hướng đối tượng - 30


while((q!=NULL)&&(strcmp((q->info).getid(),x)!=0)) q=q->link;

if(q!=NULL)

{

p=q->link; remove(q);

}

else p=NULL;

}

}

};

Có thể bạn quan tâm!

Xem toàn bộ 256 trang tài liệu này.

//lớp danh sách hoá đơn

class hdlist:public list<hoadon>

Lập trình hướng đối tượng - 30

{

private: node<hoadon> *home;

public:

long tk_nv(char *ma)

{

node<hoadon> *p; long tongtien=0; p=home; while(p!=NULL)

{

if(strcmp((p->info).getmanv(),ma)==0) tongtien+=(p->info).getgia();

p=p->link;

}

return tongtien;

}

long tk_kh(char *ma)

{

node<hoadon> *p; long tongtien=0; p=home; while(p!=NULL)

{

if(strcmp((p->info).getmakh(),ma)==0) tongtien+=(p->info).getgia();

p=p->link;

}

return tongtien;

}

long tk_mh(char *ma)

{

node<hoadon> *p; long tongtien=0;


p=home; while(p!=NULL)

{

if(strcmp((p->info).getmamh(),ma)==0) tongtien+=(p->info).getgia();

p=p->link;

}

return tongtien;

}

};

//chương trình chính

void main()

{

int chon; do

{

clrscr();

cout<<"n 1. Quan ly danh sach phong"; cout<<"n 2. Quan ly danh sach nguoi quan ly"; cout<<"n 3. Quan ly danh sach nhan vien"; cout<<"n 4. Quan ly danh sach mat hang"; cout<<"n 5. Quan ly danh sach khach hang"; cout<<"n 6. Quan ly hoa don";

cout<<"n 7. Quan ly danh sach nha cung cap"; cout<<"n 8. Ket thuc chuong trinh"; cout<<"nChon chuc nang:";cin>>chon;

switch (chon)

{

case 1: char lc,tl;

list<phong> l; do

{


sach:";

clrscr();

cout<<"na. Hien thi danh sach phong"; cout<<"nb. Tim kiem";

cout<<"nc. Bo sung phong vao danh sach"; cout<<"nd. Loai bo phong khoi danh


cout<<"ne. Thong ke so phong"; cout<<"nf. Tim truong phong"; cout<<"ng. Quay lai(nhan r):"; cout<<"n Ban chon:";cin.ignore(); cin>>lc;

switch(lc)

{

case 'a':



sungn";


phong";

l.doc_tep("phong.txt"); l.display();

getch(); break; case 'b':

char ma[5]; cout<<"Ma phong:"; cin.ignore(); cin.getline(ma,5); l.find_tt(ma); getch();

break; case 'c': phong x; clrscr();

cout<<"Nhap thong tin ve phong bo


cin>>x; l.add(x);

l.ghi_bs("phong.txt",x); break;

case 'd': cout<<"Ma phong:"; cin.getline(ma,5); l.remove(ma);

l.ghi_tep("phong.txt"); break;

case 'e':

cout<<"Co tat ca "<<l.count()<<"


getch(); break; case 'f':

list<nguoiquanly> ql; ql.doc_tep("nguoiql.txt"); cout<<"Ma phong:"; cin.getline(ma,5); ql.find_tt(ma);

getch(); break;

}

}

while(lc!='r'); break;

case 2: list<nguoiquanly> ql; ql.doc_tep("nguoiql.txt");


do

{

clrscr();

cout<<"na. Hien thi danh sach nguoi quan ly"; cout<<"nb. Tim kiem";

cout<<"nc. Bo sung nguoi quan ly vao danh sach"; cout<<"nd. Loai bo nguoi quan ly khoi danh sach:"; cout<<"ne. Thong ke so nguoi quan ly"; cout<<"nf. Tim phong";

cout<<"ng. Quay lai(nhan r):"; cout<<"n Ban chon:";

cin>>lc; switch(lc)


sungn";


ly";

{

case 'a':

ql.display();

getch(); break; case 'b':

char ma[5];

cout<<"Ma nguoi quan ly:"; cin.ignore(); cin.getline(ma,5); ql.find_tt(ma);

getch(); break; case 'c':

nguoiquanly x; clrscr();

cout<<"Nhap thong tin ve nguoi bo


cin>>x; ql.add(x);

ql.ghi_bs("nguoiql.txt",x); break;

case 'd':

cout<<"Ma nguoi quan ly:"; cin.getline(ma,5); ql.remove(ma); ql.ghi_tep("nguoiql.txt"); break;

case 'e':

cout<<"Co tat ca "<<ql.count()<<" nguoi quan


getch(); break; case 'f':


list<phong> l; l.doc_tep("phong.txt"); cout<<"Ma phong:"; cin.getline(ma,5); l.find_tt(ma);

getch(); break;

}

}

while(lc!='r'); break;

case 3:

list<nhanvien> nvl; nvl.doc_tep("nhanvien.txt");

do

{

clrscr();

cout<<"na. Hien thi danh sach nhan vien"; cout<<"nb. Tim kiem";

cout<<"nc. Bo sung nhan vien vao danh sach"; cout<<"nd. Loai bo nhan vien khoi danh sach:"; cout<<"ne. Thong ke so nhan vien"; cout<<"nf. Tim phong";

cout<<"ng. Quay lai(nhan r):"; cout<<"n Ban chon:";

cin>>lc;

switch(lc)

{

case 'a': nvl.display(); getch(); break;

case 'b': char ma[5];

cout<<"Ma nhan vien:"; cin.ignore(); cin.getline(ma,5); nvl.find_tt(ma); getch();

break; case 'c': nhanvien x; clrscr();

cout<<"Nhap thong tin ve nguoi bo

sungn";


cin>>x; nvl.add(x);



vien";

nvl.ghi_bs("nhanvien.txt",x); break;

case 'd':

cout<<"Ma nhan vien:"; cin.getline(ma,5); nvl.remove(ma); nvl.ghi_tep("nhanvien.txt"); break;

case 'e':

cout<<"Co tat ca "<<nvl.count()<<" nhan


getch(); break; case 'f':

list<phong> l; l.doc_tep("phong.txt"); cout<<"Ma phong:"; cin.getline(ma,5); l.find_tt(ma);

getch(); break;

}

}

while(lc!='r'); break;

case 4:

list<mathang> mhl; mhl.doc_tep("mathang.txt");

do

{

clrscr();

cout<<"na. Hien thi danh sach mat hang"; cout<<"nb. Tim kiem";

cout<<"nc. Bo sung mat hang vao danh sach"; cout<<"nd. Loai bo mat hang khoi danh sach:"; cout<<"ne. Thong ke so mat hang"; cout<<"nf. Tim nha cung cap";

cout<<"ng. Quay lai(nhan r):"; cout<<"n Ban chon:";

cin>>lc;

switch(lc)

{

case 'a': mhl.display(); getch(); break;

case 'b':



sungn";


hang";

char ma[5];

cout<<"Ma mat hang:"; cin.ignore(); cin.getline(ma,5); mhl.find_tt(ma); getch();

break; case 'c': mathang x; clrscr();

cout<<"Nhap thong tin ve mat hang bo


cin>>x; mhl.add(x);

mhl.ghi_bs("mathang.txt",x); break;

case 'd':

cout<<"Ma mat hang:"; cin.getline(ma,5); mhl.remove(ma); mhl.ghi_tep("mathang.txt"); break;

case 'e':

cout<<"Co tat ca "<<mhl.count()<<" mat


getch(); break; case 'f':

list<nhacungcap> l; l.doc_tep("nhacc.txt"); cout<<"Ma nha cung cap:"; cin.getline(ma,5); l.find_tt(ma);

getch(); break;

}

}

while(lc!='r'); break;

case 5:

list<khachhang> khl; khl.doc_tep("khhang.txt");

do

{


hang";

clrscr();

cout<<"na. Hien thi danh sach khach


cout<<"nb. Tim kiem";

cout<<"nc. Bo sung khach hang vao danh sach"; cout<<"nd. Loai bo khach hang khoi danh sach:"; cout<<"ne. Thong ke so khach hang"; cout<<"nf. Quay lai(nhan r):";

cout<<"n Ban chon:"; cin>>lc;

switch(lc)

{

case 'a': khl.display(); getch(); break;

case 'b': char ma[5];

cout<<"Ma khach hang:"; cin.ignore(); cin.getline(ma,5); khl.find_tt(ma); getch();

break; case 'c':

khachhang x; clrscr();

cout<<"Nhap thong tin ve khach hang bo

sungn";


hang";


cin>>x; khl.add(x);

khl.ghi_bs("khhang.txt",x); break;

case 'd':

cout<<"Ma khach hang:"; cin.getline(ma,5); khl.remove(ma); khl.ghi_tep("khhang.txt"); break;

case 'e':

cout<<"Co tat ca "<<khl.count()<<" khach


getch(); break;

}

}

while(lc!='r'); break;

case 6:

hdlist hdl;

..... Xem trang tiếp theo?
⇦ Trang trước - Trang tiếp theo ⇨

Ngày đăng: 03/07/2022