Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void borrowBooks(String id, String name, String sid, String sname) {
- if((getKeyFromValue(Books, name).equals(id))&&(getKeyFromValue(Students, sname).equals(sid))){
- if((Object)Library.countValues(sid)!=5){
- Library.put(id, sid);
- }
- else{
- System.out.println("You have exceeded your quota. Return a book before you take one out." );
- }
- }
- }
- if (Library.get(id) == null) {
- Library.put(id, new ArrayList<String>());
- }
- List<String> books = Library.get(id);
- int number = books.size() // gives you the size
- if(((Object)Library).countValues(sid) != 5)
- initialize count to 0
- for each entry in Library:
- if the value is what you want:
- increment the count
- int count = 0;
- for(String str : Library.values())
- {
- if(str == sid)
- count++;
- if(count == 5)
- break;
- }
- if(count < 5)
- Library.put(id, sid);
- else
- System.out.println("You have exceeded your quota. Return a book before you take one out." );
Add Comment
Please, Sign In to add comment