【发布时间】:2023-04-02 11:03:01
【问题描述】:
包含我的数组的构造函数:
public Library(int maxNumberofTextBook)
{
// initialise instance variables
nextBook = 0;
numberOfBorrowers = 0;
numberOfChapters = 6;
bookShelf = new Textbook[maxNumberofTextBook + 1];
for (int i = 0; i < maxNumberofTextBook; i++)
bookShelf[i] = new Textbook("Text book number" +i, numberOfChapters);
}
在这种方法中,我希望数组接受参数输入并将其添加到上面的数组中:
public void returnBook(Textbook book)
{
//add book into array//
numberOfBorrowers -- ;
bookInShelf ++ ;
}
【问题讨论】: