/* * Author: CHEN Yongyuan (Walter) 1930006025 from OOP(1007) * Date: 2022-04-25 * Description: This is the Lender class. */ public class Lender extends User { /** * Constructor. * * @param name The user's name. * @param book number of bookds lent by the user. This will be store in negetive value. */ public Lender(String name, int book) { // lender negetive book value super(name, -book); } /** * Increases the number of bookds. * * @param book the number of books. */ public void moreBook(int book) { setBook(getBook() - book); } /** * Test. */ public static void testLender() { Lender l = new Lender("Anna", 5); System.out.println(l.getName() == "Anna"); System.out.println(l.getBook() == -5); l.setBook(-6); System.out.println(l.getBook() == -6); l.moreBook(2); System.out.println(l.getBook() == -8); l.moreBook(-9); System.out.println(l.getBook() == 1); } }