@@ -0,0 +1,2530 @@
+package sortingalgorithms;%0A%0Aimport java.util.Arrays;%0A%0A/**%0A *  A TestResult-object stores the results from a test.%0A *%0A *  @author  Joel Abrahamsson%0A *  @version %25G%25%0A */%0Apublic class TestResult%0A%7B%0A  private String description;%0A  private boolean sorted;%0A  private long averageTime;%0A  private long%5B%5D times;%0A  private long totalTime;%0A%0A  /**%0A   *  Creates a new TestResult-object that keeps test results.%0A   *%0A   *  @param description  a short description of the test%0A   *  @param sorted       the data was sorted%0A   *  @param times        a list of times%0A   */%0A  public TestResult(String description, boolean sorted, long... times)%0A  %7B%0A    this.description = description;%0A    this.sorted = sorted;%0A    this.times  = times;%0A%0A    // Sort times%0A    Arrays.sort(this.times);%0A%0A    calculateTotalTime();%0A    calculateAverageTime();%0A  %7D%0A%0A  /**%0A   *  Calculates average time.%0A   */%0A  private void calculateAverageTime()%0A  %7B%0A    int length = times.length;%0A    averageTime = length %3E 0 ? totalTime / length : 0;%0A  %7D%0A%0A  /**%0A   *  Calculates total time.%0A   */%0A  private void calculateTotalTime()%0A  %7B%0A    totalTime = 0;%0A    for (long time : times)%0A      totalTime += time;%0A  %7D%0A%0A  /**%0A   *  Returns the average time it took to sort the data.%0A   *%0A   *  @return the average time it took to sort the data.%0A   */%0A  public long getAverageTime()%0A  %7B%0A    return averageTime;%0A  %7D%0A%0A  /**%0A   *  Returns the description of the TestResult-object%0A   *%0A   *  @return description of the TestResult-object%0A   */%0A  public String getDescription()%0A  %7B%0A    return description;%0A  %7D%0A%0A  /**%0A   *  Returns the max time%0A   *%0A   *  @return the max time%0A   */%0A  public long getMaxTime()%0A  %7B%0A    return times%5Btimes.length - 1%5D;%0A  %7D%0A%0A  /**%0A   *  Returns the min time%0A   *%0A   *  @return the min time%0A   */%0A  public long getMinTime()%0A  %7B%0A    return times%5B0%5D;%0A  %7D%0A%0A  /**%0A   *  Returns all times%0A   *%0A   *  @return all times%0A   */%0A  public long%5B%5D getSortTimes()%0A  %7B%0A    return times;%0A  %7D%0A%0A  /**%0A   *  Returns true if data was sorted; otherwise false.%0A   *%0A   *  @return true if data was sorted; otherwise false.%0A   */%0A  public boolean wasSorted()%0A  %7B%0A    return sorted;%0A  %7D%0A%0A  public String toString()%0A  %7B%0A    return String.format(%22%25s%5CnWas sorted: %25b%5CnAverage time: %25d ns (%25f s)%22, description,%0A                                                                           sorted,%0A                                                                           averageTime,%0A                                                                           (double)averageTime / 1000000000L);%0A  %7D%0A%7D%0A

Implement TestResult-class for storing test results