diff --git a/Assignement12/bin/HistogramDataDisplay.class b/Assignement12/bin/HistogramDataDisplay.class index 73a9c70..0178222 100644 Binary files a/Assignement12/bin/HistogramDataDisplay.class and b/Assignement12/bin/HistogramDataDisplay.class differ diff --git a/Assignement12/src/HistogramDataDisplay.java b/Assignement12/src/HistogramDataDisplay.java index 1e7b8b3..563c55f 100644 --- a/Assignement12/src/HistogramDataDisplay.java +++ b/Assignement12/src/HistogramDataDisplay.java @@ -7,28 +7,10 @@ public class HistogramDataDisplay extends DataDisplay { @Override public void update() { System.out.println(getClass() + ": " + name); - int[] sortedArray = super.getContent(); - boolean isSorted = false; - while (!isSorted) { - isSorted = true; - for (int i = 0; i < sortedArray.length - 1; i++) { - if (sortedArray[i] > sortedArray[i + 1]) { - int temp = sortedArray[i]; - sortedArray[i] = sortedArray[i + 1]; - sortedArray[i + 1] = temp; - isSorted = false; - } - } - } - int lastVal = -1; - for (int i : sortedArray) { - if (i == lastVal) - System.out.print("*"); - else { - System.out.format("%s%d\t*", (lastVal == -1) ? "" : "\n", i); - lastVal = i; - } - } + for (int i = 0; i < super.getContent().length; i++) + System.out.format("%s%d\t%s", (i == 0) ? "" : "\n", super.getContent()[i], + "*".repeat(super.getContent()[i])); + System.out.println(); } }