Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.60 KB | None | 0 0
  1. list<const Figure *> * testCompterSupprimerSiBUG()
  2. {
  3.     list<const Figure *> * figures =  new list<const Figure *>();
  4.  
  5.     Cercle * c1 = new Cercle(Point(10, 20), 2);
  6.     Cercle * c2 = new Cercle(Point(10, 20), 9);
  7.     Cercle * c3 = new Cercle(Point(10, 20), 15);
  8.     figures->push_back(new Cercle(Point(10, 20), 2));
  9.     figures->push_back(new Cercle(Point(10, 20), 9));
  10.     figures->push_back(new Cercle(Point(10, 20), 15));
  11.  
  12.     Ligne * l1 = new Ligne(Point(10, 20), Point(12, 44));
  13.     Ligne * l2 = new Ligne(Point(6, 7), Point(1, 21));
  14.     figures->push_back(new Ligne(Point(10, 20), Point(12, 44)));
  15.     figures->push_back(new Ligne(Point(6, 7), Point(1, 21)));
  16.  
  17.     Image * i1 = new Image();
  18.     i1->ajouter(*c1);
  19.     i1->ajouter(*l1);
  20.     figures->push_back(i1);
  21.  
  22.     Cercle * c4 = new Cercle(Point(10, 20), 150);
  23.     figures->push_back(new Cercle(Point(10, 20), 150));
  24.  
  25.     Image * i2 = new Image();
  26.     i2->ajouter(*c2);
  27.     i2->ajouter(*c4);
  28.     i2->ajouter(*i1);
  29.     figures->push_back(i2);
  30.  
  31.     Image * i3 = new Image();
  32.     i3->ajouter(*c3);
  33.     i3->ajouter(*c4);
  34.     i3->ajouter(*i2);
  35.     i3->ajouter(*l2);
  36.     figures->push_back(i3);
  37.  
  38.     for_each(figures->begin(), figures->end(), affiche);
  39.  
  40.     Condition * conditions[] =
  41.     {
  42.         new EstPetite(300),
  43.         new EstUn(&Cercle::temoin),
  44.         new EstUn(&Ligne::temoin),
  45.         new EstUn(&Image::temoin),
  46.         new Non(new EstUn(&Cercle::temoin)),
  47.         new Non(new EstUn(&Ligne::temoin)),
  48.         new Et(new EstUn(&Cercle::temoin), new EstPetite(300))
  49.     };
  50.  
  51.     for (unsigned int i = 0; i < sizeof(conditions)/sizeof(conditions[0]); i++)
  52.     {
  53.         int n = Filtrage::compterSi(*figures, conditions[i], true);
  54.         cout << conditions[i]->toString() << " : " << Filtrage::compterSi(*figures, conditions[i], true) << "V + ";
  55.         cout <<  figures->size() - n << "F" << endl;
  56.     }
  57.  
  58.     cout << endl << "SUPPRESSION supperficielle des cercles" <<endl;
  59.     Filtrage::supprimerSi(*figures, conditions[1]);
  60.     for_each(figures->begin(), figures->end(), affiche);
  61.  
  62.     cout << endl << "SUPPRESSION profonde des cercles" <<endl;
  63.     Filtrage::supprimerSiProfond(*figures, conditions[1]);
  64.     for_each(figures->begin(), figures->end(), affiche);
  65.  
  66.     for (unsigned int i = 0; i < sizeof(conditions) / sizeof(conditions[0]); i++)
  67.     {
  68.         cout << i << endl;
  69.         delete conditions[i];
  70.     }
  71.  
  72.     // for (auto val = figures->begin(); val != figures->end(); val++)
  73.     //   delete *val;
  74.  
  75.     delete c1;
  76.     delete c2;
  77.     delete c3;
  78.     delete c4;
  79.     delete l1;
  80.     delete l2;
  81.    
  82.     return figures;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement