никогда такого не было, и вот опять
Не обращайте внимания на константу в inputStream. Это я специально ради получения false. Валидатор не принимает с yourFile (и вообще main не должен участвовать в тестировании).
Кто скажет, как обновить прикрепленный код в вопросе, тому печенька.
package com.javarush.task.task20.task2002;
import java.text.SimpleDateFormat;
import java.util.Date;
public class User {
static final int LINES_PER_USER = 9;
private String firstName;
private String lastName;
private Date birthDate;
private boolean isMale;
private Country country;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public Date getBirthDate() {
return birthDate;
}
public void setBirthDate(Date birthDate) {
this.birthDate = birthDate;
}
public boolean isMale() {
return isMale;
}
public void setMale(boolean male) {
isMale = male;
}
public Country getCountry() {
return country;
}
public void setCountry(Country country) {
this.country = country;
}
public enum Country {
RUSSIA("Russia"),
UKRAINE("Ukraine"),
OTHER("Other");
static Country getCountry(String name) {
if ("Russia".equals(name))
return RUSSIA;
else if ("Ukraine".equals(name))
return UKRAINE;
else
return OTHER;
}
private String name;
Country(String name) {
this.name = name;
}
public String getDisplayName() {
return this.name;
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
User user = (User) o;
if (isMale != user.isMale) return false;
if (firstName != null ? !firstName.equals(user.firstName) : user.firstName != null) return false;
if (lastName != null ? !lastName.equals(user.lastName) : user.lastName != null) return false;
if (birthDate != null ? !birthDate.equals(user.birthDate) : user.birthDate != null) return false;
return country == user.country;
}
@Override
public int hashCode() {
int result = firstName != null ? firstName.hashCode() : 0;
result = 31 * result + (lastName != null ? lastName.hashCode() : 0);
result = 31 * result + (birthDate != null ? birthDate.hashCode() : 0);
result = 31 * result + (isMale ? 1 : 0);
result = 31 * result + (country != null ? country.hashCode() : 0);
return result;
}
@Override
public String toString() {
String birthDate = formatDate();
StringBuilder builder = new StringBuilder();
builder.append(hasFirstName()).append(System.lineSeparator())
.append(firstName).append(System.lineSeparator())
.append(hasLastName()).append(System.lineSeparator())
.append(lastName).append(System.lineSeparator())
.append(hasBirthDate()).append(System.lineSeparator())
.append(birthDate).append(System.lineSeparator())
.append(isMale()).append(System.lineSeparator())
.append(hasCountry()).append(System.lineSeparator())
.append(country.getDisplayName());
// число строк должно быть отражено в LINES_PER_USER
return String.valueOf(builder);
}
private String formatDate() {
if (hasBirthDate()) {
return new SimpleDateFormat("dd.MM.yyyy").format(this.birthDate);
} else {
return "null";
}
}
private boolean hasFirstName() {
return firstName != null;
}
private boolean hasLastName() {
return lastName != null;
}
private boolean hasBirthDate() {
return birthDate != null;
}
private boolean hasCountry() {
return country != null;
}
}
Никто же не знает во сколько мс он родился...