mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Added text to the exceptions for FloatList and IntList
Fixed formatting of IntList
This commit is contained in:
@@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user