Answer the question
In order to leave comments, you need to log in
How to solve an error in a test?
Please help, the test fails: assertEquals("Clint Eastwood", new Dinglemouse("Clint", "Eastwood").getFullName()); Throws an error: expected: Clint[] but was:Clint[ ]
public class Dinglemouse {
private String firstName;
private String lastName;
public Dinglemouse(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
public String getFullName() {
if(firstName != "" && lastName != "") {
return this.firstName + " " + this.lastName;
}
if(firstName == "" && lastName == "") {
return "";
}
return firstName == "" ? lastName : firstName;
}
}
Answer the question
In order to leave comments, you need to log in
Decision:
public class Dinglemouse {
private String firstName;
private String lastName;
public Dinglemouse(String firstName, String lastName){
this.firstName = firstName;
this.lastName = lastName;
}
public String getFullName() {
if(!firstName.equals("") && !lastName.equals("")){
return this.firstName + " " + this.lastName;
}
if(firstName.equals("") && lastName.equals("")){
return "";
}
return firstName.equals("") ? lastName : firstName;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question