two questions:
1) how to return a valid User object. It seems that the code does that but fail the test why?
2)The initializeIdAndName method must set the id and name fields using the arguments passed to it. which it does and yet I fail the test why?
package com.codegym.task.task13.task1320;
/*
Neo
*/
public class Solution {
public static void main(String[] args) throws Exception {
System.out.println(Matrix.NEO);
}
static class Matrix {
public static DBObject NEO = new User().initializeIdAndName(1, "Neo");
}
interface DBObject {
DBObject initializeIdAndName(long id, String name);
}
static class User implements DBObject {//The User class must implement the DBObject interface.
long id;
String name;
@Override
public DBObject initializeIdAndName(long id, String name){
//The initializeIdAndName method must set the id and name fields
//using the arguments passed to it.
this.id = id;
this.name = name;
return this;//The initializeIdAndName method must return a valid User object(what does this mean?), specifically,
//the object on which the method was called (this). what does this mean?
}
@Override
public String toString() {
return String.format("The user's name is %s, id = %d", name, id);
}
}
}