also could i put the storing element in the constructor code of book?
whats happening at the moment in the constructor since its not storing it anywhere?is it creating an object at all?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Brendan Cregan wrote:Hi,
thanks for the reply, as regards my implementation, i just need to list books that are available through the user of a boolean (isAvailable), and i just need to check them in and check them out to a user!
would an array list be ok for that functionality?
Jeff Verdegan wrote:
Brendan Cregan wrote:
That describes what you'll do with the Book after you've found it. The distinction between List and Map would be made before that, based on how you want to find it. So, as somebody already suggested, in the pile of books, are you going to be trying to retrieve the 11th book, or are you going to be trying to retrieve the book titled "Effective Java"? And do you understand how the answer to that question relates to whether you want a List or a Map?
Brendan Cregan wrote:
Jeff Verdegan wrote:
Brendan Cregan wrote:
That describes what you'll do with the Book after you've found it. The distinction between List and Map would be made before that, based on how you want to find it. So, as somebody already suggested, in the pile of books, are you going to be trying to retrieve the 11th book, or are you going to be trying to retrieve the book titled "Effective Java"? And do you understand how the answer to that question relates to whether you want a List or a Map?
Hi Again Jeff,
would it not be possible for me to use the idea of getting the 11th book as a book id?
i don't need to search by book name just to return books of a certain category i.e. isAvailable?the specific functionality im aiming for is
list items by
all items in the library (available and not available)
all items by category (books, periodicals, dvds)
all available items in a category (e.g. all books that are not on loan)
Brendan Cregan wrote:Hi Jeff,
When you say list do you mean the arraylist that i was talking about?sorry just want to have it clear in my own mind
Thanks again for the help
Brendan
Jeff Verdegan wrote:
Brendan Cregan wrote:Hi Jeff,
When you say list do you mean the arraylist that i was talking about?sorry just want to have it clear in my own mind
Thanks again for the help
Brendan
I mean any implementation of the List interface. ArrayList is the usual default go-to List implementation. If you're selecting books by index, than that would be a reason to choose ArrayList, as its random access is O(1), whereas for LinkedList, it's O(n). On the other hand, if you're going to be doing a lot of adding or removing anywhere but at the end of the list, the LinkedList might be a more appropriate choice.
Brendan Cregan wrote:Hi,
im having trouble implementing my arraylist, i think it could be because it has multiple data types(int and string).
Is that allowed in an arraylist?getting conflicting answers in my searches.
this is how i created it
and this is how i tried to add in a book
getting a strange compiling error i havent seen before as well
"Note: Library.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details."
Any ideas?
Don't get me started about those stupid light bulbs. |