Hi! - PowerPoint PPT Presentation

slide1 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Hi! PowerPoint Presentation
play fullscreen
1 / 13
Hi!
150 Views
Download Presentation
davida
Download Presentation

Hi!

- - - - - - - - - - - - - - - - - - - - - - - - - - - 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