Added text to the exceptions for FloatList and IntList

Fixed formatting of IntList
This commit is contained in:
Patrick Vares
2015-01-21 15:26:24 -05:00
parent aee68cdf29
commit faf989a5b9
2 changed files with 28 additions and 20 deletions
+8 -4
View File
@@ -423,6 +423,10 @@ public class FloatList implements Iterable<Float> {
}
private String exceptionText(int count, int index, String method){
return "The list size is "+count+". Trying to "+method+" the element at "+index+" which does not exist.";
}
/**
* @webref floatlist:method
* @brief Add to a value
@@ -431,7 +435,7 @@ public class FloatList implements Iterable<Float> {
if (index < count) {
data[index] += amount;
} else {
throw new IndexOutOfBoundsException();
throw new ArrayIndexOutOfBoundsException(exceptionText(count, index, "add"));
}
}
@@ -444,7 +448,7 @@ public class FloatList implements Iterable<Float> {
if (index < count) {
data[index] -= amount;
} else {
throw new IndexOutOfBoundsException();
throw new ArrayIndexOutOfBoundsException(exceptionText(count, index, "sub"));
}
}
@@ -457,7 +461,7 @@ public class FloatList implements Iterable<Float> {
if (index < count) {
data[index] *= amount;
} else {
throw new IndexOutOfBoundsException();
throw new ArrayIndexOutOfBoundsException(exceptionText(count, index, "mult"));
}
}
@@ -470,7 +474,7 @@ public class FloatList implements Iterable<Float> {
if (index < count) {
data[index] /= amount;
} else {
throw new IndexOutOfBoundsException();
throw new ArrayIndexOutOfBoundsException(exceptionText(count, index, "div"));
}
}
+20 -16
View File
@@ -407,16 +407,20 @@ public class IntList implements Iterable<Integer> {
data[index]++;
}
private String exceptionText(int count, int index, String method){
return "The list size is "+count+". Trying to "+method+" the element at "+index+" which does not exist.";
}
/**
* @webref intlist:method
* @brief Add to a value
*/
public void add(int index, int amount) {
if( index < count) {
data[index] += amount;
if (index < count) {
data[index] += amount;
} else {
throw new IndexOutOfBoundsException();
}
throw new IndexOutOfBoundsException(exceptionText(count, index, "add"));
}
}
/**
@@ -424,11 +428,11 @@ public class IntList implements Iterable<Integer> {
* @brief Subtract from a value
*/
public void sub(int index, int amount) {
if( index < count) {
data[index] -= amount;
if (index < count) {
data[index] -= amount;
} else {
throw new IndexOutOfBoundsException();
}
throw new IndexOutOfBoundsException(exceptionText(count, index, "sub"));
}
}
/**
@@ -436,11 +440,11 @@ public class IntList implements Iterable<Integer> {
* @brief Multiply a value
*/
public void mult(int index, int amount) {
if( index < count) {
data[index] *= amount;
if (index < count) {
data[index] *= amount;
} else {
throw new IndexOutOfBoundsException();
}
throw new IndexOutOfBoundsException(exceptionText(count, index, "mult"));
}
}
/**
@@ -448,11 +452,11 @@ public class IntList implements Iterable<Integer> {
* @brief Divide a value
*/
public void div(int index, int amount) {
if( index < count) {
data[index] /= amount;
if (index < count) {
data[index] /= amount;
} else {
throw new IndexOutOfBoundsException();
}
throw new IndexOutOfBoundsException(exceptionText(count, index, "div"));
}
}