public class BubbleSortTest
{

  public static void bubbleSort(Comparable[] obj)
  { int length = obj.length-1;
    boolean swap = true;
    while(swap)
    { swap = false;
      for (int i=0; i < length; i++)
      { 
        int compareTo = obj[i+1].compareTo(obj[i]);
        if (compareTo< 0)
        { Comparable<Comparable> tmp = obj[i];
          obj[i] = obj[i+1];
          obj[i+1] = tmp;
          swap = true;
        }
      }
      length--;
    }
  }

  
  public static String arrayToStr(Object[] array)
  { String str = "{";
    final String space = ", ";
    for (int i = 0; i<array.length-1; i++)
    { str = str + array[i] + space;
    }
    return str + array[array.length-1] + "}";
  }


  public static void main(String[] args)
  { System.out.println("Test 1: 3 unique names"); 
    Employee[] a = new Employee[3];
    a[0] = new Employee("Seth", "Pershan", 225000.0);
    a[1] = new Employee("Don", "Swartz", 5023.52);
    a[2] = new Employee("Chris", "Frazier", 1200000.0);
    bubbleSort(a); 
    System.out.println(arrayToStr(a));

    System.out.println("\nTest 2: 8 unique names, 2xEng, IgnoreCase=true"); 
    a = new Employee[8];
    a[0] = new Employee("Timothy", "Eng", 25000.0);
    a[1] = new Employee("Don", "Swartz", 5023.52);
    a[2] = new Employee("Qian", "Yu", 1200000.0);
    a[3] = new Employee("Sylvain", "Bernard", 25000.0);
    a[4] = new Employee("Anthony", "Haider", 322.0);
    a[5] = new Employee("Alex", "WOODY", 25000.0);
    a[6] = new Employee("Sophia", "Eng", 31500.0);
    a[7] = new Employee("Chrys", "Watson-Ross", 25000.0);
    bubbleSort(a); 
    System.out.println(arrayToStr(a));
    
    
    System.out.println("\nTest 3: 8 unique names, 2xEng, IgnoreCase=false"); 
    for (int i=0; i<a.length; i++) {a[i].setIgnoreCase(false);}
    bubbleSort(a); 
    System.out.println(arrayToStr(a));
    
    System.out.println("\nTest 4: 1 name"); 
    a = new Employee[1];
    a[0] = new Employee("Anthony", "Haider", 322.0);
    bubbleSort(a); 
    System.out.println(arrayToStr(a));
    
    System.out.println("\nTest 5: 6 names, IgnoreCase=true"); 
    a = new Employee[6];
    a[0] = new Employee("DD", "RR", 25000.0);
    a[1] = new Employee("cc", "AA", 5023.52);
    a[2] = new Employee("aa", "RR", 1200000.0);
    a[3] = new Employee("ZZ", "DD", 25000.0);
    a[4] = new Employee("BB", "RR", 322.0);
    a[5] = new Employee("XX", "AA", 25000.0);
    bubbleSort(a); 
    System.out.println(arrayToStr(a));
    
  }
}







 