大家好,我有一个程序是图书馆管理程序
我有一个名为 borrowHolding(holdingId)throws BalanceLow, InvalidHolding 的方法,我从模型接口调用该方法,该接口调用外观类,将方法调用传递给库类,但从这里方法定义在接口借用者中声明,另一个接口成员扩展了这个借用者接口然后 AbstractMember 实现了 borrowHoling 方法,可以将小代码片段清晰:
所有导入都是正确的,并且每个类和接口都在不同的类中分开。
public interface LMSModel {
public void borrowHolding(int holdingId)
throws InsufficientCreditException, MultipleBorrowingException;
}
public class LMSFacade implements LMSModel {
private Library lib = new Library();
private Member member;
public void borrowHolding(int holdingId)
throws InsufficientCreditException, MultipleBorrowingException {
// TODO Auto-generated method stub
lib.borrowHolding(holdingId);
}
}
public class Library {
public Member member;
public void borrowHolding(int holdingId) throws InsufficientCreditException, MultipleBorrowingException {
member.borrowHolding(holdingId);
}
}
public interface Member extends Borrower{
public abstract Holding[] getCurrentHoldings();
public abstract double getMaxCredit();
public abstract void resetCredit();
public abstract String getFullName();
public abstract String getMemberId();
}
public abstract class AbstractMember implements Member, Borrower {
public void borrowHolding(int holdingId)
throws InsufficientCreditException, MultipleBorrowingException {
// TODO Auto-generated method stub
System.out.println("Hello");
// Map<Integer, Holding> LibHoldingMap = libCollection.holdingMap;
// holding = (Holding)LibHoldingMap.get((Integer)holdingId);
//
// if (holding.isOnLoan()) {
// System.out.println("Can not be issued Currently on Load");
// } else {
// System.out.println("Can be issued");
// }
}
}
public interface Borrower {
void borrowHolding(int holdingId)throws InsufficientCreditException, MultipleBorrowingException;
}
当我调用borrowHolding 我得到nullPointerException 我不知道该方法不能被调用不知道为什么。