1 / 13

Hi!

Hi!. Nhóm 10 0812495 Phí Quang Thịnh 0812527 Huỳnh Công Toàn 0812549 Trần Đức Trí 0812631 Nguyễn Tuấn Vũ 0812637 Trần Vũ. Design Pattern. Bài tập 1. Câu a ( Biểu diễn). Câu b ( Hàm khởi tạo ). Biểu thức hằng. BieuThucHang :: BieuThucHang (){ this-> hangSo = 0; }

davida
Download Presentation

Hi!

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Hi! Nhóm 10 • 0812495 Phí Quang Thịnh • 0812527 Huỳnh Công Toàn • 0812549 Trần Đức Trí • 0812631 Nguyễn Tuấn Vũ • 0812637 Trần Vũ

  2. Design Pattern Bàitập 1

  3. Câua (Biểu diễn)

  4. Câub (Hàmkhởitạo) Biểuthứchằng BieuThucHang::BieuThucHang(){ this->hangSo = 0; } BieuThucHang::BieuThucHang(double hangSo){ this->hangSo = hangSo; } Biểuthứcđơn BieuThucDon::BieuThucDon(){ this->heSo = 0; this->soMu = 1; } BieuThucDon::BieuThucDon(doubleheSo, doublesoMu){ this->heSo = heSo; this->soMu = soMu; }

  5. Câub (Hàmkhởitạo) Biểuthứctổng BieuThucTong::BieuThucTong(){ this->bieuThuc1 = NULL; this->bieuThuc2 = NULL; } BieuThucTong::BieuThucTong(BieuThuc* bt1, BieuThuc* bt2){ this->bieuThuc1 = bt1; this->bieuThuc2 = bt2; } Biểuthứctích BieuThucTong::BieuThucTong(){ this->bieuThuc1 = NULL; this->bieuThuc2 = NULL; } BieuThucTich::BieuThucTich(BieuThuc* bt1, BieuThuc* bt2){ this->bieuThuc1 = bt1; this->bieuThuc2 = bt2; }

  6. Câub (Hàmkhởitạo) Biểuthức chia BieuThucChia::BieuThucChia(){ this->bieuThuc1 = NULL; this->bieuThuc2 = NULL; } BieuThucChia::BieuThucChia(BieuThuc* bt1, BieuThuc* bt2){ this->bieuThuc1 = bt1; this->bieuThuc2 = bt2; }

  7. Câuc (Tínhgiátrị) doubleBieuThucHang::tinhGiaTri(double x){ returnhangSo; } Biểuthứchằng doubleBieuThucDon::tinhGiaTri(double x){ doublekq = 1; for(inti=0; i<soMu; i++) kq = kq*x; returnheSo*kq; } Biểuthứcđơn doubleBieuThucTong::tinhGiaTri(double x){ return bieuThuc1->tinhGiaTri(x) + bieuThuc2->tinhGiaTri(x); } Biểuthứctổng

  8. Câuc (Tínhgiátrị) doubleBieuThucTich::tinhGiaTri(double x){ return bieuThuc1->tinhGiaTri(x) * bieuThuc2->tinhGiaTri(x); } Biểuthứctích doubleBieuThucChia::tinhGiaTri(double x){ return bieuThuc1->tinhGiaTri(x) / bieuThuc2->tinhGiaTri(x); } Biểuthức chia

  9. Câuc (Tínhđạohàm) • BieuThuc* BieuThucHang::tinhDaoHam(){ • BieuThuc* kq = newBieuThucHang(); • returnkq; • } Biểuthứchằng • BieuThuc* BieuThucDon::tinhDaoHam(){ • doubleheSoMoi = heSo*soMu; • doublesoMuMoi = soMu - 1; • BieuThuc* btkq = newBieuThucDon(heSoMoi, soMuMoi); • returnbtkq; • } Biểuthứcđơn

  10. Câuc (Tínhđạohàm) Biểuthứctổng • BieuThuc* BieuThucTong::tinhDaoHam(){ • BieuThuc* daoHambt1 = bieuThuc1->tinhDaoHam(); • BieuThuc* daoHambt2 = bieuThuc2->tinhDaoHam(); • BieuThuc* kq = newBieuThucTong(daoHambt1, daoHambt2); • returnkq; • } • BieuThuc* BieuThucTich::tinhDaoHam(){ • BieuThuc* daoHambt1 = bieuThuc1->tinhDaoHam(); • BieuThuc* daoHambt2 = bieuThuc2->tinhDaoHam(); • BieuThuc* tich1 = newBieuThucTich(daoHambt1, bieuThuc2); • BieuThuc* tich2 = newBieuThucTich(daoHambt2, bieuThuc1); • BieuThuc* kq = newBieuThucTong(tich1, tich2); • returnkq; • } Biểuthứctích

  11. Câuc (Tínhđạohàm) • BieuThuc* BieuThucChia::tinhDaoHam(){ • BieuThuc* daoHambt1 = bieuThuc1->tinhDaoHam(); • BieuThuc* daoHambt2 = bieuThuc2->tinhDaoHam(); • BieuThuc* tich1 = newBieuThucTich(daoHambt1, bieuThuc2); • bieuThuc1->daoDauBieuThuc(); • BieuThuc* tich2 = newBieuThucTich(daoHambt2, bieuThuc1); • BieuThuc* kqTu = newBieuThucTong(tich1, tich2); • BieuThuc* kqMau = newBieuThucTich(bieuThuc2, bieuThuc2); • BieuThuc* kq = newBieuThucChia(kqTu, kqMau); • returnkq; • } Biểuthức chia

  12. Câud (kiểmtra)

  13. Hỏi & Đáp

More Related