From 5a45b0ca3ed77bf4f8240d51957336a0db50f6e4 Mon Sep 17 00:00:00 2001 From: Eugene Fischer Date: Thu, 11 Jun 2020 12:17:33 -0500 Subject: [PATCH] Add number range to output --- Sorting/AlgorithmTester.java | 2 +- Sorting/SortResult.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Sorting/AlgorithmTester.java b/Sorting/AlgorithmTester.java index efe8bc0..07b6e6f 100644 --- a/Sorting/AlgorithmTester.java +++ b/Sorting/AlgorithmTester.java @@ -174,7 +174,7 @@ public class AlgorithmTester{ } System.out.print("\n"); } - System.out.println("\n"+e.getSortType()+" of "+e.getSortCount()+" numbers took:"); + System.out.println("\n"+e.getSortType()+" of "+e.getSortCount()+" numbers with range "+e.getMin()+" to "+e.getMax()+" took:"); System.out.println(e.getComparisonsUsed()+" comparisons"); System.out.println(e.getWritesUsed()+" write operations"); System.out.println(e.getTimeUsed()+" milliseconds"); diff --git a/Sorting/SortResult.java b/Sorting/SortResult.java index 1dc09a1..e339c7b 100644 --- a/Sorting/SortResult.java +++ b/Sorting/SortResult.java @@ -75,4 +75,14 @@ public class SortResult { return nf.format(sortedArray.length); } + public String getMin(){ + NumberFormat nf = NumberFormat.getInstance(Locale.US); + return nf.format(sortedArray[0]); + } + + public String getMax(){ + NumberFormat nf = NumberFormat.getInstance(Locale.US); + return nf.format(sortedArray[sortedArray.length-1]); + } + } \ No newline at end of file