I am trying to build a program where I have a visual representation of an int array while they get sorted. There will be two different search algorithms of choice. All the functionality is split up into classes, interfaces and abstract classes. My main problem is getting the data from one thing to the next.
My main class implements basic window functionality. Paints the window, a few buttons to choose the search algorithm, provides a textfield to input an array and displays in its center a bar graph visualisation of the array.
Drawing the bars is done in a class that extends JComponent. This is also where I transform the String of numbers into an int array. I can already draw the graphs, change the array and it gets also drawn.
Now I have an interface called Sorter which provides the following methods.
public void setUpTo( int i ); // to limit the number of swaps during the search
public void setNumbers( int[] numbers );
public void sort();
public String getName();
public int getSwaps();
Then I have the abstract class CountingSort that implements Sorter and the class CountingBubbleSort which extends CountingSort.
This is all pretty confusing to me.
Within my main class I listen to a button to pass on the content of TextField and start the sorting.
What do I need to do to get the int array through CountingSort into CountingBubbleSort?
I have already implemented CountingBubbleSort.
Let me know what additional information I need to provide.
CountingBubbleSort#setNumbers?CountingBubbleSort? Then callsetNumbers(...)(and all required methods) for that instance.