From a0235424641490793cd699ac9cc34a3343e9a5cb Mon Sep 17 00:00:00 2001 From: asri71 Date: Thu, 28 Feb 2019 16:57:18 +0530 Subject: [PATCH] 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); +}