Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java forum!

Ryan Hodgson

Greenhorn
+ Follow
since Jan 06, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ryan Hodgson

yeah what ever is best for you. we got a choice but was told swing would be easier so went with it.
1 week ago

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

admin:


controller:

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



oh sorry i never knew about making new post, next time i know to make new post. i dunno why im making two loans wasnt what i was trying to do. yeah that would be great if you could do that. would be greatly appreciated. thanks
1 week ago
so im back at this project and am trying to make the loan and bring in an instance of member and media because my thought is link the media to the member by the members username and medias title. so ive made a method to create loans but dont think its right because when i sign in as member and try list loan it returns 0 null null. any thoughts if i should do a better way? i thought about your idea of CheckedOut class but cant i just make that my loan one? thanks



controller where methos is to check member against members list


admin screen where loans are created.
1 week ago

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.



he said that was a way to do it not we have to do it that way i must of wrote that bit bad. i was looking at it the wrong way a friend gaveme few ideas and im understanding it better. i was just been bit stupid
2 weeks ago

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



ok thanks i will have a look, i just need to see how add loans to members tbh rest of programme done. a friend told me to just have the arraylist in members and bring in stock id with methods addLoan(stockID) and removeLoan(stockID) so am going to try implement it but will have a look at yours as well to hopfully get a better
understanding,

Thanks a lot, its much appreciated!!
2 weeks ago

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.



thanks for the reply, it is a swing application i am building so have alot of JFrame classes for doing task such as adding new members and media etc. at start up they are all pre populated in Model class and sends messages to the controller with the member and media details. my main method creates an instance of controller "new Controller();" and then runs from there. i am only using the date as a string the now as a starting point so if i can get it working i have something to display to test.

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. so if i try and create the loans in the model it cant find arraylist and doesnt create loans.

i will try implement it by adding an instance of member to the loan class and see if i can get it working.

thanks for the reply its given a better insight of what i should be trying to do.
2 weeks ago
i am making a library style programme where different types of users can log in with different privileges such as admins and members. admin users process the loans and members can take the loans. they can borrow different media such as books and dvds etc. i have an arraylist of "users" in a model class and an arraylist of type "loan" in the users class. i know i need to reference the "media" class in the "loan" class as thats what the users will be able to borrow. ive been reading about coupling and object referencing for about a week and am just getting lost. where do i create the "loan" objects if i want to pre-populate the arraylist with a few loans, and have it so i can call it and create some loans when needed etc.  if anyone can point me in the right direction or give any help it would be greatly appreciated.

member class.

Media class.


Loan class.



2 weeks ago