From a0235424641490793cd699ac9cc34a3343e9a5cb Mon Sep 17 00:00:00 2001 From: asri71 Date: Thu, 28 Feb 2019 16:57:18 +0530 Subject: [PATCH 1/2] Addint type package to have interfaces to take benefit of polymorphism features --- src/main/java/com/sorts/BubbleSort.java | 6 +++++- src/main/java/com/types/Sort.java | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/types/Sort.java diff --git a/src/main/java/com/sorts/BubbleSort.java b/src/main/java/com/sorts/BubbleSort.java index 81793551..c532a646 100644 --- a/src/main/java/com/sorts/BubbleSort.java +++ b/src/main/java/com/sorts/BubbleSort.java @@ -1,12 +1,16 @@ package src.main.java.com.sorts; -public class BubbleSort { +import src.main.java.com.types.Sort; + +public class BubbleSort implements Sort { /** * This method implements the Generic Bubble Sort * * @param array The array to be sorted * Sorts the array in increasing order **/ + + @Override public > T[] sort(T[] array) { int last = array.length; //Sorting diff --git a/src/main/java/com/types/Sort.java b/src/main/java/com/types/Sort.java new file mode 100644 index 00000000..ea919e24 --- /dev/null +++ b/src/main/java/com/types/Sort.java @@ -0,0 +1,6 @@ +package src.main.java.com.types; + +public interface Sort { + + public > T[] sort(T[] array); +} From ed53bd0353b6ad4bf098fd6d5435fba018282631 Mon Sep 17 00:00:00 2001 From: asri71 Date: Thu, 28 Feb 2019 17:10:08 +0530 Subject: [PATCH 2/2] Making Sort interface as functional interface to exhibit the nature and functionality of the interface more clearly to client --- src/main/java/com/types/Sort.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/types/Sort.java b/src/main/java/com/types/Sort.java index ea919e24..da89756f 100644 --- a/src/main/java/com/types/Sort.java +++ b/src/main/java/com/types/Sort.java @@ -1,5 +1,6 @@ package src.main.java.com.types; +@FunctionalInterface public interface Sort { public > T[] sort(T[] array);