public boolean checkIn(Book b1) { if (b1.getPerson() != null) { b1.setPerson(null); return true; } else { return false; } }
@Test public void testGetPerson() { Book b1 = new Book("Learn SQL"); Person p1 = new Person("John Doe"); b1.setPerson(p1); Person testPerson = b1.getPerson(); assertEquals(p1, testPerson); assertEquals("John Doe", testPerson.getName()); }
public boolean checkOut(Book b1, Person p1) { int booksOut = this.getBooksForPerson(p1).size(); if ((b1.getPerson() == null) && (booksOut < p1.getMaximumBooks())) { b1.setPerson(p1); return true; } else { return false; } }
@Test public void testToString() { Book b5 = new Book("Learn SQL", "John Doe"); String s = "Learn SQL by John Doe - Available"; // System.out.println(b5.getPerson().getName()); assertEquals(s, b5.toString()); b5.setPerson(new Person("User")); s = "Learn SQL by John Doe - Unavailable"; assertEquals(s, b5.toString()); }