/* * BubCorrecto().[add(int)]*.bubbleSort() * Mutantes que nos interesan: los que afecten a las operaciones * BubCorrecto, add(int), bubbleSort y swap(int, int) */ package paper; import java.util.Vector; public class BubCorrecto { private Vector elements; public BubCorrecto() { elements = new Vector(); } // put element into array public void add(int value) throws IllegalArgumentException { if (value<0) throw new IllegalArgumentException(); elements.add(new Integer(value)); } public void bubbleSort() { int out, in; for (out = elements.size()-1; out > 0; out--) for (in = 0; in < out; in++) { Integer x=(Integer) elements.get(in); Integer y=(Integer) elements.get(in+1); if (x.intValue()>y.intValue()) swap(in, in + 1); } } private void swap(int i, int j) { Integer temp = (Integer) elements.get(i); elements.setElementAt(elements.get(j), i); elements.setElementAt(temp, j); } public int get(int i) { Integer value=(Integer) elements.get(i); return value.intValue(); } public int size() { return this.elements.size(); } public Vector getVector(){ return elements; } }