Guest User

Untitled

a guest
May 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. package org.totalbeginner.tutorial;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. public class MyLibrary {
  6.  
  7. Object name;
  8. ArrayList<Book> books;
  9. ArrayList<Person> people;
  10.  
  11. public MyLibrary(String name) {
  12. this.name = name;
  13.  
  14. people = new ArrayList<Person>();
  15. books = new ArrayList<Book>();
  16. }
  17.  
  18. public Object getName() {
  19. return name;
  20. }
  21.  
  22. public ArrayList<Book> getBooks() {
  23. return books;
  24. }
  25.  
  26. public ArrayList<Person> getPeople() {
  27. return people;
  28. }
  29.  
  30. public void addBook(Book b1) {
  31. this.books.add(b1);
  32.  
  33. }
  34.  
  35. public void removeBook(Book b1) {
  36. this.books.remove(b1);
  37.  
  38. }
  39.  
  40. public void addPerson(Person p1) {
  41. this.people.add(p1);
  42.  
  43. }
  44.  
  45. public void removePerson(Person p1) {
  46. this.people.remove(p1);
  47.  
  48. }
  49.  
  50. public boolean checkOut(Book b1, Person p1) {
  51. if (b1.getPerson() == null) {
  52. b1.setPerson(p1);
  53. return true;
  54. }
  55. else {
  56. return false;
  57. }
  58. }
  59.  
  60. public boolean checkIn(Book b1) {
  61. if (b1.getPerson() != null) {
  62. b1.setPerson(null);
  63. return true;
  64. }
  65. else {
  66. return false;
  67. }
  68. }
  69.  
  70.  
  71. }
Add Comment
Please, Sign In to add comment