Can I use my objects without fully populating them?
Posted
by LuckySlevin
on Stack Overflow
See other posts from Stack Overflow
or by LuckySlevin
Published on 2010-06-08T20:54:44Z
Indexed on
2010/06/08
22:42 UTC
Read the original article
Hit count: 170
java
I have situation. I have to create a Sports Club system in JAVA. There should be a class your for keeping track of club name, president name and braches the club has. For each sports branch also there should be a class for keeping track of a list of players. Also each player should have a name, number, position and salary. So, I come up with this. Three seperate classes:
public class Team
{
String clubName;
String preName;
Branch []branches;
}
public class Branch
{
Player[] players;
}
public class Player
{
String name;
String pos;
int salary;
int number;
}
The problems are creating Branch[] in another class and same for the Player[]. Is there any simplier thing to do this? For example, I want to add info for only the club name, president name and branches of the club, in this situation, won't i have to enter players,names,salaries etc. since they are nested in each other. I hope i could be clear. For further questions you can ask.
© Stack Overflow or respective owner