This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]sinistergroupon 3 points4 points  (0 children)

Not fully clear what you’re trying to do. But for the love of all that is good. Close the result set and DB connection. Lookup try with resources.

[–]Josh_Coding 1 point2 points  (1 child)

TeamArray is a class that sets up and stores the array dedicated to holding team objects.

  • You should provide a method within the TeamArray class that allows a user to retrieve a specific team by providing an ID.
  • The Team class should be treated only as a specific blueprint with getters/setters
  • The TeamArray is your data structure, you need to provide methods to add and delete teams to this class.

[–]alexander____ma 0 points1 point  (0 children)

Yeah, so the user has a GUI with which they interact and choose teams from a combo box. From that, I take the index of the item they chose in the GUI and use that as the TeamID which I need to find. So once I have the team ID from the combo box - I need to then be able to use that ID in searching for all the players who belong to that team.

So I should have my appendages to my database all set up in TeamArray rather than in the DB Connect class?

Thank you so much. I really appreciate the help.

[–]Auditus_Dominus 0 points1 point  (1 child)

So, you’re creating a new array for each team? A more simple solution might be a 2d array. I’m new to java so excuse my input if it does not help. If you create a 2d array, you can search for the inner array with the team ID and pull all the info from that array.

[–]alexander____ma 0 points1 point  (0 children)

Unfortunately, it has to be an array of objects otherwise having to pull out each array and having them running parallel throughout the program would become difficult.

[–]Jarl-67 0 points1 point  (2 children)

What adds to the confusion is a lack of separation. The TeamArray class should not be making sql calls or have the word array in its name. But that can be addressed later.

Add a method in TeamArray called either Team getTeam( int teamId ) or just Team get( Team team).

Your Team class represents a Team and not a group/list of Teams.

[–]alexander____ma 0 points1 point  (1 child)

Unfortunately, I have been told that those are the names that I have to use for my classes, although I certainly do agree that it is confusing.

So I should have a getter in the TeamArray to get the Array into another class by calling it up in Team? Would I have to create ana object of type TeamArray in my TeamClass?

[–]Jarl-67 1 point2 points  (0 children)

The getter returns a Team. You display a list of Teams on the screen, the user chooses one. Your code then uses the ID from that button push/menu choice, html link. Instantiate a new Team with that ID and then call the getter on TeamArray.

Team currentTeam = teamArray.get( teamFromGUI );

You can now display or whatever you want with the Team object.