重写java Eques()方法-不工作吗?
equals()
ArrayList
Book
addBook()
, removeBook()
hasBook()
Book
Cart
public boolean equals(Book b) { ... // More code here - null checks if (b.getID() == this.getID()) return true; else return false;}
Cart
equals(TYPE var)
equals(Object o) { (CAST) var }
Book
ID
public boolean hasBook(int i) { Book b = new Book(i); return hasBook(b);}public boolean hasBook(Book b) { // .. more code here return this.books.contains(b);}
equals(Book b)
Cart
equals()
public boolean equals(Object o) { Book b = (Book) o; ... // The rest goes here }
Book
一只斗牛犬
MYYA
白猪掌柜的