Advertisement
Guest User

Untitled

a guest
Apr 21st, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Library{
  4.  
  5. public Library(){
  6. }
  7.  
  8. public void getFinishedBooks(HashMap<String, Boolean> library){
  9. if (library.size() < 1){
  10. System.out.println("Error the HashMap is empty");
  11. }
  12.  
  13. else {
  14. for (String book : library.keySet()){
  15. if (library.get(book) == true){
  16. System.out.println (book);
  17. }
  18. }
  19. }
  20. }
  21.  
  22. public static void main(String[] args)
  23. {
  24.  
  25. HashMap<String, Boolean> myBooks = new HashMap<String, Boolean>();
  26.  
  27. myBooks.put("Road Down the Funnel", true);
  28. myBooks.put("Rat: A Biology", false);
  29. myBooks.put("TimeIn", true);
  30. myBooks.put("3D Food Printing", false);
  31.  
  32. Library myLibrary = new Library();
  33.  
  34. myLibrary.getFinishedBooks(myBooks);
  35.  
  36.  
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement