educative.io

How does the BookItem's checkout method have a reference to BookLending?

I was wondering how it can just access BookLending in the Java example code? Wouldn’t it have to pass a reference to BookLending in the method?

  public boolean checkout(String memberId) {
    if(bookItem.getIsReferenceOnly()) {
      ShowError("This book is Reference only and can't be issued");
      return false;
    }
    if(!BookLending.lendBook(this.getBarCode(), memberId)){
      return false;
    }
    ...
2 Likes