Question: PLEASE HELP This has you implementing bubble sort and insertion sort. In addition to BufferOfDoubles.java and BufferWithSort.java. The code will be implemented in a subclass
PLEASE HELP
This has you implementing bubble sort and insertion sort. In addition to BufferOfDoubles.java and BufferWithSort.java.
The code will be implemented in a subclass of BufferOfDoubles. A child subclass can access everything in the parent super class as if it were part of that class. Here, the functions in the child BufferWithSort subclass should work as if they were written in the parent BufferOfDoubles super class.



Here is my BufferOfDoubles function which needs to be integrated.
public class BufferOfDoubles {
protected double[] arrayOfValues;
protected int numberOfValues;
public BufferOfDoubles(int size) {
arrayOfValues = new double[size];
numberOfValues = 0;
}
public boolean add(double value) {
if (numberOfValues
arrayOfValues[numberOfValues] = value;
numberOfValues++;
return true;
} else
return false;
}
public int addArray(double[] array, int firstIndex, int lastIndex) {
int count = 0;
for (int i = firstIndex; i
if (i >= 0 && i
count++;
return count;
}
public int findFirst(double value) {
for (int i = 0; i
if (arrayOfValues[i] == value)
return i;
return -1;
}
public int findLast(double value) {
for (int i = numberOfValues - 1; i >= 0; i--)
if (arrayOfValues[i] == value)
return i;
return -1;
}
public boolean removeStable(int index) {
if (index >= 0 && index
numberOfValues--;
for (int i = index; i
arrayOfValues[i] = arrayOfValues[i + 1];
return true;
} else
return false;
}
public boolean removeQuick(int index) {
if (index >= 0 && index
numberOfValues--;
arrayOfValues[index] = arrayOfValues[numberOfValues];
return true;
} else
return false;
}
public void clear() {
numberOfValues = 0;
}
public void display() {
for (int i = 0; i
System.out.format("%.2f ", arrayOfValues[i]);
}
System.out.println();
}
public void displayAsTable(int numberOfColumns) {
for (int i = 0; i
if (i > 0 && i % numberOfColumns == 0)
System.out.println();
System.out.format("%8.3f", arrayOfValues[i]);
}
System.out.println();
}
}
This is what the final outupt should be.

This is the starting code for the basic version of BufferWithSort followed by the expected output. public class BufferwithSort extends BufferOfDoubles public BufferwithSort (int size) f super (size); private void swap (int indexA, int indexB) // ToDo: your code goes here private void bubble(int lengthOverwhichToBubble // ToDo: your code goes here private int // ToDo: your code goes here return 0; public void bubbleSort() /I ToDo: your code goes here public void selectionSort) { /I ToDo: your code goes here public void shuffle) for (inti-0; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
