Given an array of Strings, write a method that determines if there is a "Tyrannosaurus" within the array. If there is, the method returns true. If there isn't or the the array is empty, your method should return false.
Assume the array will only contain Strings.
Examples:
{"Brontosaurus", "Stegosaurus", "Velociraptor"} -> false
{"Boba Fett", "Palm Tree", "Tyrannosaurus", "Croissant"} -> true
public class findT_Rex {
public static boolean containsT_Rex(String[] things) {
//insert code!
return true;
}
}
import org.junit.Test;
import static org.junit.Assert.assertEquals;
// TODO: Replace examples and use TDD by writing your own tests
class SolutionTest {
@Test
public void tests() {
String[] things1 = new String[] {"Triceratops", "Megalosaurus", "Spinosaurus", "Archaeopteryx"};
String[] things2 = new String[] {"Jackie Chan", "Charlize Theron", "Tyrannosaurus", "Tom Hardy", "Ruby Rose"};
String[] things3 = new String[] {""};
// assertEquals("expected", "actual");
assertEquals(false, containsT_Rex(things1));
assertEquals(true, containsT_Rex(things2));
assertEquals(false, containsT_Rex(things3));
}
}