Question: Solve the code in java Sovle the error in nameLookup class ( picture of error provided ) public class NameLookup implements Lookup { private String

Solve the code in java
Sovle the error in nameLookup class (picture of error provided)
public class NameLookup implements Lookup {
private String prefix;
public NameLookup(String name){
this.prefix = name;
}
public boolean matches(Product product){
if (prefix == null && product.getName()== null){
return true; // Both prefix and product name are null, consider them equal
}
if (prefix != null && prefix.equals(product.getName())){
return true; // Prefix is not null, and product name matches prefix
}
return false; // Otherwise, consider them not equal
}
}
Failed: Hint: two names with null values are considered equal ==> expected: org.opentest4j.AssertionFailedError: Hint: two names with null values are considere:
at org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:55)
at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:40)
at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:193)
at InstructorTest$NameLookupTest.testNoMatch1
 Solve the code in java Sovle the error in nameLookup class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!