JavaRanch-FAQ HowToAskQuestionsOnJavaRanch UseCodeTags DontWriteLongLines ItDoesntWorkIsUseLess FormatCode JavaIndenter SSCCE API-11 JLS JavaLanguageSpecification MainIsAPain KeyboardUtility
Paul Clapham wrote:Are you referring to the inputBookToDelete() method, which creates a new (presumably empty) library and then tries to delete books from it?
Kevin O'Sullivan wrote:
Paul Clapham wrote:Are you referring to the inputBookToDelete() method, which creates a new (presumably empty) library and then tries to delete books from it?
Yup well that method takes the input and then the method in Library class deleteBooks() is suppose to take care of the deleting .
Carey Brown wrote:Your problem is that you are creating new libraries all over the place. In your entire project you should only be creating one new Library to represent the Cork Library. You have also made most of your fields public which is allowing inputs of new books a back door into a library from which delete succeeds.
Paul Clapham wrote:
Kevin O'Sullivan wrote:
Paul Clapham wrote:Are you referring to the inputBookToDelete() method, which creates a new (presumably empty) library and then tries to delete books from it?
Yup well that method takes the input and then the method in Library class deleteBooks() is suppose to take care of the deleting .
Like Carey said. Just create one Library. And it should have only one list of books (i.e. making that a static variable is wrong).
JavaRanch-FAQ HowToAskQuestionsOnJavaRanch UseCodeTags DontWriteLongLines ItDoesntWorkIsUseLess FormatCode JavaIndenter SSCCE API-11 JLS JavaLanguageSpecification MainIsAPain KeyboardUtility
Kevin, when you make a change and then say "nope, it doesn't work" we can't help you unless you show us all the code again.Kevin O'Sullivan wrote:yup did this as well but still have the same problem, not deleting any hardcoded books.
JavaRanch-FAQ HowToAskQuestionsOnJavaRanch UseCodeTags DontWriteLongLines ItDoesntWorkIsUseLess FormatCode JavaIndenter SSCCE API-11 JLS JavaLanguageSpecification MainIsAPain KeyboardUtility
BTW this will force you to UNDO (almost?) all of those statics.Carey Brown wrote:
JavaRanch-FAQ HowToAskQuestionsOnJavaRanch UseCodeTags DontWriteLongLines ItDoesntWorkIsUseLess FormatCode JavaIndenter SSCCE API-11 JLS JavaLanguageSpecification MainIsAPain KeyboardUtility
Carey Brown wrote:
Kevin, when you make a change and then say "nope, it doesn't work" we can't help you unless you show us all the code again.Kevin O'Sullivan wrote:yup did this as well but still have the same problem, not deleting any hardcoded books.
Norm Radder wrote:Also posted here: https://www.javaprogrammingforums.com/whats-wrong-my-code/43659-delete-method-not-deleting-hard-coded-books.html
Please read: https://coderanch.com/wiki/660346/Wiki/Forthright-Cross-Posting-Sites
Campbell Ritchie wrote:Where did you read about hashCode() and equals()? What did they say? I worry about randomly‑found online tutorials; most of them are poor quality.
I recommend you find Effective Java by Joshua Bloch (old edition here), Odersky Sppon and Venners, and search for Angelika Langer Java equals() hashCode(). Make sure to get the English edition of Langer.
Kindly don't delete your questions, neither here nor on the other forum.
JavaRanch-FAQ HowToAskQuestionsOnJavaRanch UseCodeTags DontWriteLongLines ItDoesntWorkIsUseLess FormatCode JavaIndenter SSCCE API-11 JLS JavaLanguageSpecification MainIsAPain KeyboardUtility
Campbell Ritchie wrote:Not bad. Can you do it with the removeIf() method?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
A wop bop a lu bob a womp bam boom. Tutti frutti ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
|