Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tri;
- import java.util.Scanner;
- import java.util.Arrays;
- public class TestTri {
- public static void main (String args[]) {
- //Tableau a trier
- Pays[] array = new Pays[10];
- array[0] = new Pays("Uruguay", 176220);
- array[1] = new Pays("thailand", 514000);
- array[2] = new Pays("Belgium", 30510);
- array[3] = new Pays("Argentina", 2766890);
- array[4] = new Pays("Canada", 9984670);
- array[5] = new Pays("France", 643427);
- array[6] = new Pays("Chile", 756950);
- array[7] = new Pays("Denmark", 43094);
- array[8] = new Pays("Estonia", 45226);
- array[9] = new Pays("Germany", 357021);
- //déclaration de la variable de calcul du temps
- long startTime;
- long estimatedTime;
- //déclaration des variables pour le choix du tri
- Scanner sc = new Scanner(System.in);
- int choixTri = 6;
- //boucle générale du test
- boolean quit = false;
- while(quit == false) {
- //boucle pour le choix du tri
- while(choixTri > 5) {
- System.out.println("1 : Tri par séléction");
- System.out.println("2 : Tri par insertion");
- System.out.println("3 : Tri rapide");
- System.out.println("4 : Tri rapide 2");
- System.out.println("5 : Quitter");
- System.out.println("Sélection du numéro du tri à tester :");
- choixTri = sc.nextInt();
- }
- if(choixTri == 1) {
- System.out.println("Choix 1 : Tri par séléction");
- TriParSelection tri = new TriParSelection(array);
- startTime = System.currentTimeMillis();
- tri.trier();
- System.out.println(Arrays.toString(array));
- estimatedTime = System.currentTimeMillis() - startTime;
- System.out.println("\n Le tri du tableau a été effectué en " +estimatedTime +" ms \n");
- }
- else if(choixTri == 2) {
- System.out.println("Choix 2 : Tri par insertion");
- TriParInsertion tri = new TriParInsertion(array);
- startTime = System.currentTimeMillis();
- tri.trier();
- System.out.println(Arrays.toString(array));
- estimatedTime = System.currentTimeMillis() - startTime;
- System.out.println("\n Le tri du tableau a été effectué en " +estimatedTime +" ms \n");
- }
- else if(choixTri == 3) {
- System.out.println("Choix 3 : Tri rapide");
- QuickSorter tri = new QuickSorter(array);
- startTime = System.currentTimeMillis();
- tri.trier();
- System.out.println(Arrays.toString(array));
- estimatedTime = System.currentTimeMillis() - startTime;
- System.out.println("\n Le tri du tableau a été effectué en " +estimatedTime +" ms \n");
- }
- else if(choixTri == 4) {
- System.out.println("CHoix 4 : Tri rapide 2");
- QuickSorter2 tri = new QuickSorter2(array);
- startTime = System.currentTimeMillis();
- tri.trier();
- System.out.println(Arrays.toString(array));
- estimatedTime = System.currentTimeMillis() - startTime;
- System.out.println("\n Le tri du tableau a été effectué en " +estimatedTime +" ms \n");
- }
- else if(choixTri == 5) {
- System.out.println("Choix 5 : Quitter");
- QuickSorter2 tri = new QuickSorter2(array);
- quit = true;
- }
- else {
- System.out.println("\n Erreur, veuillez réessayer \n");
- }
- //réinitialisation du choix
- choixTri = 6;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement