• Post Reply Bookmark Topic Watch Topic
  • New Topic

An object which is a reference to a list of objects  RSS feed

 
Ariana Hobson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two classes:

Location.class


Branch.class


I have two JLists. Let say London has 3 branches whereas Manchester has 2 branches. What I want to appear in my JLists:

JList A:
Location (Total branches)
e.g
London (3)
Manchester (2)

So I want my JList B to look like this:
JList B:
Location - BranchNo. (Number of employees)
e.g
London - Branch 1 (50)
London - Branch 2 (40)
London - Branch 3 (60)
Manchester - Branch 4 (34)
Manchester - Branch 5 (55)

I want a function where when I delete London from JList A, it will also delete all the branches in London from JList B.
When I add a new branch in London, it will update the total branches in London to 4.
Can someone guide me on where I should start?


Thank you.
 
Knute Snortum
Sheriff
Posts: 4287
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your Branch class is going to need a unique identifier, like an ID, so that you can find the unique branch in a list of branches. Otherwise, you won't know which branch to to delete.

This is sounding very Database like. Are there enough locations and branches to justify that? If not, maybe a Hash with an ID as a key.
 
Charles D. Ward
Ranch Hand
Posts: 99
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you have a constructor for Student in your Location class?
 
Ariana Hobson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Charles D. Ward wrote:Why do you have a constructor for Student in your Location class?

Ah yes. I forgot to change the constructor name. Sorry about it! Is there even an edit button??
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ariana Hobson wrote:
Ah yes. I forgot to change the constructor name. Sorry about it! Is there even an edit button??


Posts that have been responded to, are no longer allowed to be edited.

Henry
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!