Results 1 to 2 of 2
Thread: Help with Objects!
- 07-10-2007, 08:33 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 1
- Rep Power
- 0
Help with Objects!
I need to make a Data object for each team in a league. I started by making an array of the objects, but then I could only access the objects by the array index which caused me all kinds of inheritance problems.
My question is, is there a way of creating objects with the team names?
For example, say I have an array of strings teamNames[20] containing all the teams in the Premiership, can I create objects named with these team names without doing it manually?
So, if goalsScored is an attribute of the Data object, and getGoalsScored() is a method, I want to be able to get the number of goals scored with Liverpool.getGoalsScored();
And then, ideally: (teamString).getGoalsScored();
Is this possible?
Any suggestions welcome. Thanks!
- 07-10-2007, 09:32 PM #2
Why don't you create a Team class like this:
Create your teams array like this:Java Code:class Team { String name; public void String getName(); }
and then search for the team by checking names of them in a for loop.Java Code:Team[20] teams;
That is the logical method of doing this. Why do you need your implementation?
Similar Threads
-
Color objects
By CyberFrog in forum New To JavaReplies: 4Last Post: 04-01-2008, 12:41 AM -
Getting objects from a list
By markyoung1984 in forum New To JavaReplies: 4Last Post: 03-13-2008, 10:45 PM -
Objects and Classes
By Aleve in forum New To JavaReplies: 8Last Post: 12-31-2007, 08:05 AM -
how can objects themselves be copied???
By ishakteyran in forum New To JavaReplies: 1Last Post: 12-29-2007, 10:04 AM -
JSP implicit objects
By Java Tip in forum Java TipReplies: 0Last Post: 12-26-2007, 10:12 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks