Advertisement
Guest User

Untitled

a guest
Apr 25th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. /*
  2. * Copyright (c) 2015 SSI Schaefer Noell GmbH
  3. *
  4. * $Header: /data/cvs/Scolarizare/Team1/LibraryManagement/src/com/ssn/team1/librarymanagement/BooksContainer.java,v 1.2 2015/04/23 11:01:42 cpopescu Exp $
  5. */
  6.  
  7. package com.ssn.team1.librarymanagement;
  8.  
  9. import java.io.Serializable;
  10. import java.util.HashMap;
  11.  
  12. /**
  13. * @author <a href="mailto:ipopesc@ssi-schaefer-noell.com">ipopesc</a>
  14. * @version $Revision: 1.2 $, $Date: 2015/04/23 11:01:42 $, $Author: cpopescu $
  15. */
  16.  
  17. public class BooksContainer implements Serializable {
  18. private static final long serialVersionUID = 1L;
  19. private HashMap<String, Book> booksMap = new HashMap<String, Book>();
  20. private static BooksContainer instance = new BooksContainer();
  21.  
  22. //instance = Database.getInstance().getBooksContainer();
  23. private BooksContainer() {
  24. //booksMap = new HashMap<String, Book>();
  25. }
  26.  
  27. public static BooksContainer getInstance() {
  28. return instance;
  29. }
  30.  
  31. private void loadBooksFromDatabase() {
  32. // TODO temporar
  33. // Database booksDatabase = Database.getInstance().loadDatabase();
  34. }
  35.  
  36. public void addBook(String title, String author) {
  37. Book b = new Book(title, author);
  38. booksMap.put(title + author, b);
  39.  
  40. }
  41.  
  42. // public boolean chekIfBookExists(String title, String author) {
  43. // return booksMap.containsKey(title + author);
  44. // }
  45. //
  46. // public ArrayList<Book> searchBook(String info) {
  47. // ArrayList<Book> foundBooks = new ArrayList<Book>();
  48. // for (String key : booksMap.keySet()) {
  49. // if (key.contains(info)) {
  50. // foundBooks.add(booksMap.get(key));
  51. // }
  52. // }
  53. // return foundBooks;
  54. // }
  55.  
  56. public void print() {
  57. // Database.getInstance().print();
  58. System.out.println("Books: ");
  59. System.out.println(booksMap);
  60. }
  61.  
  62. public void clear() {
  63. booksMap.clear();
  64. }
  65.  
  66. public String toString() {
  67. return booksMap.toString();
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement