nafis nibir 958a7a976a ? | 6 лет назад | |
---|---|---|
.gitignore | 6 лет назад | |
.travis.yml | 6 лет назад | |
DuplicateDeleter.java | 6 лет назад | |
IntegerDuplicateDeleter.java | 6 лет назад | |
IntegerDuplicateDeleterTest.java | 6 лет назад | |
README.md | 6 лет назад | |
StringDuplicateDeleter.java | 6 лет назад | |
StringDuplicateDeleterTest.java | 6 лет назад | |
package.bluej | 6 лет назад | |
pom.xml | 6 лет назад |
Instructions
IntegerDuplicateDeleter
and StringDuplicateDeleter
both inherit from the abstract class DuplicateDeleter
. The DuplicateDeleter
class has two required methods that the IntegerDuplicateDeleter and StringDuplicateDeleter need to implement. You need to add the two methods into the two classes and add a constructor to call the DuplicateDeleter
method to make your code compile.IntegerDuplicateDeleter
, with a composite Integer[]
object, write a method
removeDuplicatesExactly
which removes all values in the array which occur exactly the specified number of times.removeDuplicates
which removes all values in the array which occur at least the specified number of times.
StringDuplicateDeleter
, with a composite String[]
object, write a method
removeDuplicatesExactly
which removes all values in the array which occur exactly the specified number of times.removeDuplicates
which removes all values in the array which occur at least the specified number of times.Restrictions
Collection
, List
, Map
)removeDuplicateExactly(n)
Sample Script
// : Given
Integer[] array = new Integer[]{1, 1, 1, 23, 23, 56, 57, 58};
DuplicateDeleter<Integer> deleter = new IntegerDuplicateDeleter(array);
// : When
Integer[] actual = deleter.removeDuplicateExactly(3);
// : Then
Integer[] expected = new Integer[]{23, 23, 56, 57, 58};
assertArrayEquals(expected, actual);
Sample Script
// : Given
Integer[] array = new Integer[]{1, 1, 1, 23, 23, 56, 57, 58};
DuplicateDeleter<Integer> deleter = new IntegerDuplicateDeleter(array);
// : When
Integer[] actual = deleter.removeDuplicateExactly(1);
// : Then
Integer[] expected = {1, 1, 1, 23, 23};
assertArrayEquals(expected, actual);
Sample Script
// : Given
Integer[] array = new Integer[]{0, 0, 0, 1, 1, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5};
DuplicateDeleter<Integer> deleter = new IntegerDuplicateDeleter(array);
// : When
Integer[] actual = deleter.removeDuplicateExactly(3);
// : Then
Integer[] expected = {1, 1, 2, 4, 4, 5, 5, 5, 5};
assertArrayEquals(expected, actual);
removeDuplicates(n)
Sample Script
// : Given
Integer[] array = new Integer[]{1,1,1,23,23,56,57,58};
DuplicateDeleter<Integer> deleter = new IntegerDuplicateDeleter(array);
// : When
Integer[] actual = deleter.removeDuplicateExactly(1);
// : Then
Integer[] expected = {};
assertArrayEquals(expected, actual);
Sample Script
// : Given
Integer[] array = new Integer[]{0, 0, 0, 1, 1, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5};
DuplicateDeleter<Integer> deleter = new IntegerDuplicateDeleter(array);
// : When
Integer[] actual = deleter.removeDuplicates(2);
// : Then
Integer[] expected = {2};
assertArrayEquals(expected, actual);
Sample Script
// : Given
Integer[] array = new Integer[]{0, 0, 0, 1, 1, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5};
DuplicateDeleter<Integer> deleter = new IntegerDuplicateDeleter(array);
// : When
Integer[] actual = deleter.removeDuplicates(3);
// : Then
Integer[] expected = {1, 1, 2, 4, 4};
assertArrayEquals(expected, actual);
Sample Script
// : Given
Integer[] array = new Integer[]{0, 0, 0, 1, 1, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5};
DuplicateDeleter<Integer> deleter = new IntegerDuplicateDeleter(array);
deleter.removeDuplicates(0);
deleter.removeDuplicates(1);
deleter.removeDuplicates(2);
// : When
Integer[] actual = deleter.removeDuplicates(3);
// : Then
Integer[] expected = {1, 1, 2, 4, 4};
assertArrayEquals(expected, actual);
Sample Script
// : Given
Integer[] array = new Integer[]{1, 1, 1, 23, 23, 56, 57, 58};
DuplicateDeleter<Integer> deleter = new IntegerDuplicateDeleter(array);
deleter.removeDuplicates(0);
deleter.removeDuplicates(1);
deleter.removeDuplicates(2);
// : When
Integer[] actual = deleter.removeDuplicatesExactly(3);
// : Then
Integer[] expected = {23, 23, 56, 57, 58};
assertArrayEquals(expected, actual);