We need two books - this book which invokes the method and that book which will be the argument for the method.
// determine whether this book was published before that book
boolean olderThan(Book that){...}
b1.olderThan(b2) -- expected: false b2.olderThan(b1) -- expected: true
We need to add to the basic template the fields of that book.
boolean olderThan(Book that){...}
... this.title ... ... that.title ...
... this.author ... ... that.title ...
... this.price ... ... that.title ...
... this.year ... ... that.title ...
}
boolean olderThan(Book that){...}
return this.year < that.year;
}
b1.olderThan(b2) == false b2.olderThan(b1) == true