Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-10-2007, 09:33 PM
Member
 
Join Date: Jul 2007
Posts: 1
Shorinhio is on a distinguished road
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!
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-10-2007, 10:32 PM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
Why don't you create a Team class like this:

Code:
class Team { String name; public void String getName(); }
Create your teams array like this:

Code:
Team[20] teams;
and then search for the team by checking names of them in a for loop.

That is the logical method of doing this. Why do you need your implementation?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Color objects CyberFrog New To Java 4 04-01-2008 01:41 AM
Getting objects from a list markyoung1984 New To Java 4 03-13-2008 11:45 PM
Objects and Classes Aleve New To Java 8 12-31-2007 09:05 AM
how can objects themselves be copied??? ishakteyran New To Java 1 12-29-2007 11:04 AM
JSP implicit objects Java Tip Java Tips 0 12-26-2007 11:12 AM


All times are GMT +3. The time now is 11:16 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org