我有一堂书课。我想在列表末尾添加一个元素
public class Book {
private String title;
private String authorName;
private double price;
/**
* @param title
* @param authorName
* @param price
*/
public Book(String title, String authorName, double price) {
setTitle(title);
setAuthorName(authorName);
setPrice(price);
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAuthorName() {
return authorName;
}
public void setAuthorName(String authorName) {
this.authorName = authorName;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = Math.abs(price);
}
}
和一个 Booklist 类,它有一个方法 append 将书籍添加到列表中,但我无法弄清楚如何将值输入到列表中
public class BookList {
/**
* books will be stored in an array of strings
*/
private Book[] books;
// *** TODO *** you will need to add more private members variables
public BookList(int N) {
// TODO Auto-generated method stub
}
public void append(Book book) throws BookListFull {
// TODO Auto-generated method stub
}
}
我想在列表末尾添加元素请帮我怎么做谢谢