Menu

Error in MyLibrary class on toString method.

Jeanne
2011-01-30
2013-04-09
  • Jeanne

    Jeanne - 2011-01-30

    In lesson 15 of the total beginner lessons I have an error I can not figure out. In the MyLibrary.java class I added this but get an error on the getName().

       "The method getName is undefined for type MyLibrary".

    public String toString() {
    return this.getName() + " " +
    this.getBooks().size() + " books " +
    this.getPeople().size() + " people.";
    }

    Could someone give me a clue as to what would cause this error message. The getName() is in the Person.java class as follows:
    public String getName() {
    return name;
    }

     
  • Jeanne

    Jeanne - 2011-01-30

    Well never mind. I posted this after going through all the lessons again looking for what I missed and did not see it. Then I posted this then and went to look at your code in support document again and finally saw my mistake.  I had not add the method getName to the MyLibrary.java class like you did and I was thinking MyLibrary would have picked it up from the Person.java class. But that is not the case.

    Oh and these lessons are really wonderful. Thank you so much.. Jeanne

     

Log in to post a comment.