Example #1
0
void testMortJoueur()
{
    Partie partie("Partie 1", 2, 2);
    Joueur *j1 = NULL, *j2 = NULL;
    Plateau *pl = NULL;
    Action *action = new Action();
    Sort *sort = NULL;
    vector<string> listeSort;
    listeSort.push_back("Boule de Feu");
    listeSort.push_back("Sceau de Controle");
    partie.initialiser();
    j1 =  partie.ajouterJoueur("Tarte", "pika", listeSort);
    j2 =  partie.ajouterJoueur("Platon", "Sala", listeSort);
    partie.demarrerPartie();
    pl = partie.getPlateau();
    sort = UsineSort::fabriqueSort("Boule de Feu");
    sort->setProprietaire(j2);
    action->setOrigine(NULL);
    action->setSort(sort);
    action->ajouterCible(pl->getCase(0,0));
    j2->diminuerMana(j2->getManaActuel());
    assert(j2->getManaActuel() == 0);
    partie.effectuerAction(action, j2);
    assert(j2->estMort() == true);
    assert(j2->getManaMaximum() == 0);
    assert(pl->getCase(0,0)->getDefenseActuelle() == pl->getCase(0,0)->getDefenseInitiale());
    delete action;
    delete sort;
}
Example #2
0
void test()
{
    const int SIZE=10;
    int array[SIZE];
    Sort s;
    
    // array mit Zufallszahlen kleiner als SIZE fuellen
    for(int i=0; i<SIZE; ++i)
        array[i] = rand()%SIZE;

    // alle Zahlen in einer Zeile ausgeben
    for(int i=0; i<SIZE; ++i)
        cout << array[i] << ' ';
    
    // sortieren
    s.bubbleSort(array, SIZE);
    cout << " ->  ";

    // nach dem sortieren ausgeben
    for(int i=0; i<SIZE; ++i)
        cout << array[i] << ' ';
    
    // zum pruefen des Sortier-Algorithmus: ist eine Zahl groesser
    // als der darauffolgende Wert? (dann hat unser Algorithmus 
    // fehlerhaft gearbeitet.
    for(int i=0; i<SIZE-1; ++i){
        if(array[i] > array[i+1]){
            cout << "Fehler!" << endl;
            
            // wartet auf Tastendruck
            cin.get();    
        };
    };
    cout << endl;
};
Example #3
0
int main(int argc, const char * argv[]) {
    
    int a[] = {6, 1, 2, 5, 3, 4, 2};
    Sort var = *new Sort;
    var.mergeSort(a, 7);
    
    for(int i=0; i<7;i++){
        cout<<a[i]<<'\t';
    }
}
Example #4
0
int main(){
    Sort<asc> test;
    int *lista=new int[11];
    int e=0;
    for(int i=11;i>-1;--i){
	lista[e]=i;++e;
    }
    imprimir(lista,lista+11);
    test.burbuja(lista,lista+11);
    imprimir(lista,lista+11);
}
Example #5
0
int main() {
  Sort s;
  int arry[] = {3,2,6,1};
  s.insertionSort( arry, 4 );
  cout << endl;
  for ( int i = 0; i < 4; ++i ) {
    cout << arry[i] << " ";
  }
  cout << endl;
  return 0;
}
Example #6
0
int main(int argc, char const* argv[])
{
    int a[] = {1, 45, 2, 69, 6, 88};
    int size = sizeof a/sizeof (a[0]);
    // merge(a, 0, size/2, size);
    Sort t;
    t.mergeSort (a, 0, size-1);
    for (int i=0; i<size; ++i)
        std::cout << a[i] << "\t";
    std::cout << std::endl;
    return 0;
}
Example #7
0
void ReceptionClient::traitementInfoSort()
{
    char* argument[6] = {NULL};
    Sort* sort = NULL;
    Case* caseCible = NULL;
    Joueur* proprietaire = NULL;
    int x = -1, y = -1, duree = -1;
    unsigned int id = 0;
    for(int i = 0; i < 6; i++)
    {
        argument[i] = strtok (NULL, SEPARATEUR_ELEMENT);
    }
    for(int i = 0; i < 6; i++)
    {
        if(argument[i] == NULL)
        {
            //Info fausse
            return;
        }
    }
    x = atoi(argument[4]);
    y = atoi(argument[5]);
    duree = atoi(argument[3]);
    id = atoi(argument[1]);

    sort = this->partie->getSort(Position::fabriquePosition(x, y), id);
    //Sort inexistant sur la case
    if(sort == NULL)
    {
        sort = UsineSort::fabriqueSort(argument[0]);
        //Pas de sort de ce nom
        if(sort == NULL)
        {
            return;
        }
        proprietaire = this->partie->getJoueur((argument[2]));
        //Pas de joueur de ce nom
        if(proprietaire == NULL)
        {
            return;
        }
        sort->setProprietaire(proprietaire);
        sort->setId(id);
        caseCible = this->partie->getCase(Position::fabriquePosition(x, y));
        //Pas de case à cette position
        if(caseCible != NULL)
        {
            caseCible->ajouterSort(sort, duree);
        }
    }
}
Example #8
0
int main()
{
  start = clock();
  ifstream In("Elements.in");
  cin.rdbuf(In.rdbuf());

  Sort S;
  
  S.QuickSort();
  S.Display();


  end = clock();

  cout << "Time:" << (double)(end-start)/CLOCKS_PER_SEC << "S" << endl;
  return 0;
}
Example #9
0
void measure_one(Sort& sort)
{
    auto start = system_clock::now();
    sort.sort();
    auto end = system_clock::now();
    
    std::string name = sort.name();
    std::stringstream name_ss;
    name_ss << std::setw(10) << std::left << name;
    //name_ss << name << std::setw(10);
    if ( sort.check() ) {
	auto duration = duration_cast<milliseconds>(end-start).count();
	std::stringstream time_ss;
	time_ss << std::setw(12) << duration;
	std::cout << name_ss.str() << ": " << time_ss.str() << "[ms]" << std::endl;
    } else {
	// failure
	std::cout << name_ss.str() << ": sort failed" << std::endl;
    }
}
Example #10
0
void List_C::sort() {
    sort_function->sort(this);
}
Example #11
0
void Vector_C::sort() {
    sort_function->sort(this);
}