contains() Preconditions
Thecontains(x)
method checks to see if the x
value is within the array.Precondition #1
Objective 2 for this lab
Read the javadoc for the contains() method of BoundedArray. It mentions the precondition as 'value of 'x' must be in range 'minVal' and 'maxVal' INCLUSIVE' where x is the value being searched for.
Your second objective for this lab is to write code which ensures that the above precondition is met. Enter your code in the following section inside the search() method.
// Check for the 'contains()' preconditions // INSERT CODE HERE
Next you should write two unit test cases checking if the above code works. Enter the testing code in the following section of the main method.
case 7: { // 7: contains(x), where x < minVal // INSERT CODE HERE } break; case 8: { // 8: contains(x), where x > maxVal // INSERT CODE HERE }