Hi All,
According to Judge - two of the four requirements don't seem to have been passed, which is invalid.
As you can see, the overridden method both returns a User and initialize the User's fields
name
and id
Any chance of finding out why this code hasn't been validated?
Thank you in advance! :) package com.codegym.task.task13.task1306;
/*
Buggy initializeIdAndName
*/
public class Solution {
public static void main(String[] args) throws Exception {
System.out.println(Matrix.NEO);
System.out.println(Matrix.TRINITY);
}
static class Matrix {
public static DBObject NEO = new User().initializeIdAndName(1, "Neo");
public static DBObject TRINITY = new User().initializeIdAndName(2, "Trinity");
}
interface DBObject {
default DBObject initializeIdAndName(long id, String name) {
return this;
}
}
static class User implements DBObject {
private long id;
private String name;
@Override
public String toString() {
return String.format("The user's name is %s, id = %d", name, id);
}
@Override
public DBObject initializeIdAndName(long id, String name) {
this.id = id;
this.name = name;
return User.this;
}
}
}