






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







Given the following Java code, draw its complete (include fields and method information) UML class diagram. public interface Cd { public int maxmem(); } public class En { public String rev; } public class Rw { public int len; public double ms; } public class Ve { public int id; public String desc; } public class Pl extends Ve implements Cd { private String n; private int max; public int maxmem() { return max; } public Pl(String n, int max) { this.n = n; this.max = max; } public void lan(Rw r) { System.out.println("Processing " + r.len); } public String toString() { return n + "---" + max; } }
The linearSearch method returns the array index where searchValue appears in the array, or -1 if searchValue is not part of the array. You can assume elements of the array are unique. public static int linearSearch(String[] array, String searchValue) { int searchIndex = -1; for (int i=0; i<array.length; i++) { if (array[i].equals(searchValue)) { searchIndex = i; } } return searchIndex; } A possible JUnit test for this code is the following: public class MyTests extends TestCase { String[] data = new String[]{"JL", "MJ", "PK"}; public void testOne() { assertTrue(Utilities.linearSearch(data, "MJ")==1); } } a. Using the data array provided above, write as many assertions you understand are necessary to verify the correctness of the linearSearch method. You don’t need to provide JUnit test cases; just assertions (e.g., assertTrue(…)). b. Are there any assertion(s) the above code will fail?