Daniel Demesmaecker wrote:If you have a new question, olkease post in a new thread. For now it dosn't mather, one of the mods is most likely gonna move it anyway.
My checkOutClass is your LoanClass, just the name is different
This would be the LoanClass:
So basicly the same as you have
Why are you creating a loan twice?
I just cleaned up your code a bit, didn't really change anything, if you wan't I could try working out an example
Junilu Lacar wrote:
Ryan johnston wrote:i have the loan attribute in my fullmember class as that was how i was told how to do it so that the member would hold an arraylist of loans inside it.
I assume this is some kind of school work then and that it was your instructor who told you to do it that way. That's not really comforting to know. That design quickly falls apart and becomes unwieldy when you need to do something else like print a report of all media, in alphabetical order, along with who has loaned it if it is out on loan or who loaned it last if it is not out on loan. Or if you want to print out a list of items that are overdue.
so if i try and create the loans in the model it cant find arraylist and doesnt create loans.
This sounds like a very procedural-minded approach that will violate all kinds of object-oriented design principles, encapsulation and data hiding being at the top of the list.
Daniel Demesmaecker wrote:This applications screams for a db.
you're using swing? I did about the same project but in javaFx,
If you wanna have a look, you can find it on git.
Keep in mind that it's written a long time ago and I never fully finished it, but it works (allthough most likely still has a couple of bugs) and should give you a pretty good idea
Junilu Lacar wrote:As to the question about where you would populate a list of initial Loan objects, I would expect something like that to be done by some kind of initialization process that is kicked off when the application is run. Where that is exactly we can't really say right now because you haven't shared any details about what kind of application this is and how you're running it.
If it is a command-line program, then it would be a method that gets called from main() or somewhere close to that.