| java.lang.Object U2.T2.examples.TestArray1
TestArray1 | public class TestArray1 (Code) | | This class maintains an internal array of size 10. The class
invariant requires that all elements of the array should be
non-negative. The class contains errors.
|
Constructor Summary | |
public | TestArray1() Create an array of size 10, all elements initialized to 0. |
Method Summary | |
public boolean | classinv() Specifying that the elements of the internal array should be
non-negative. | public void | increase(int b) Increases this array with the values given in b. | public void | increase(int delta) Will increase all elements by some specified integer, if it is
non-negative. |
TestArray1 | public TestArray1()(Code) | | Create an array of size 10, all elements initialized to 0.
|
classinv | public boolean classinv()(Code) | | Specifying that the elements of the internal array should be
non-negative.
|
increase | public void increase(int b)(Code) | | Increases this array with the values given in b. This method
has errors. Firstly it doesn't check that b size is at least
10. T2 should be able to find this error. Secondly, if b
contains negative numbers, after the increase the internal
array may violate the class invariant. Repair the first error,
and see that T2 can also discover the second error.
|
increase | public void increase(int delta)(Code) | | Will increase all elements by some specified integer, if it is
non-negative.
|
|
|