daily pastebin goal
65%
SHARE
TWEET

Untitled

a guest Jun 22nd, 2018 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public void borrowBooks(String id, String name, String sid, String sname) {
  2.     if((getKeyFromValue(Books, name).equals(id))&&(getKeyFromValue(Students, sname).equals(sid))){
  3.         if((Object)Library.countValues(sid)!=5){
  4.             Library.put(id, sid);
  5.         }
  6.         else{
  7.             System.out.println("You have exceeded your quota. Return a book before you take one out." );
  8.         }
  9.     }
  10. }
  11.    
  12. if (Library.get(id) == null) {
  13.    Library.put(id, new ArrayList<String>());
  14. }
  15. List<String> books = Library.get(id);
  16. int number = books.size() // gives you the size
  17.    
  18. if(((Object)Library).countValues(sid) != 5)
  19.    
  20. initialize count to 0
  21. for each entry in Library:
  22.     if the value is what you want:
  23.         increment the count
  24.    
  25. int count = 0;
  26.  
  27. for(String str : Library.values())
  28. {
  29.     if(str == sid)
  30.         count++;
  31.     if(count == 5)
  32.         break;
  33. }
  34.  
  35. if(count < 5)
  36.     Library.put(id, sid);
  37. else
  38.     System.out.println("You have exceeded your quota. Return a book before you take one out." );
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top