Results 1 to 2 of 2
- 12-15-2011, 03:17 AM #1
Member
- Join Date
- Dec 2011
- Posts
- 1
- Rep Power
- 0
Returning get() method in put() method in a Hash Map
Hi, I'm new to the site and just have a quick question about a project I'm working on.
I'm making a Library catalogue program, and working on the checkoutItem() method. It's a method that checks out an item if not already checked out. If the book is not checked out, get() should return null.
Could anyone lend a hand?Java Code:/** * Return who has given book * Null if not checked out. */ public Patron whoHas(Item i) { return checkoutsMap.get(i); } /** *Uses WhoHas() method for this public boolean checkOutItem(Item i, Patron p) { if(whoHas(i)) { return null; } checkoutsMap.put(i, p); //Assign item variable to patron variable in the Hash Map }
-WpbopsLast edited by Eranga; 12-15-2011 at 03:18 AM. Reason: code tags added
- 12-15-2011, 04:02 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,544
- Rep Power
- 11
Similar Threads
-
My method keeps returning 0
By ToolJob in forum New To JavaReplies: 11Last Post: 03-27-2011, 05:22 PM -
Returning Value from a method
By Mirix in forum New To JavaReplies: 12Last Post: 06-01-2010, 09:48 PM -
Inherited method returning bad value
By viking90 in forum New To JavaReplies: 11Last Post: 04-07-2010, 03:53 PM -
returning an object from a method
By bigj in forum New To JavaReplies: 7Last Post: 01-08-2010, 12:39 PM -
Need help. Method won't returning proper value..
By zlwilly in forum New To JavaReplies: 2Last Post: 12-02-2008, 09:44 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks