[英]Java Dictionary Objects & Array/Linked List
I have a player class, these players have attributes to a Statbook, and that Statbook has 130 attributes that are of the Dictionary class. 我有一个玩家类,这些玩家具有Statbook的属性,并且Statbook具有Dictionary类的130个属性。 I want to find the most efficient way to group these players into a team (team class) and I want to know what to use: multidimensional array, linked list, etc. I know that i can use the Enumerate method to populate whatever it is that I end up using, but I need help figuring out what to use.
我想找到最有效的方法将这些玩家分组为一个团队(团队班级),并且我想知道使用什么:多维数组,链接列表等。我知道我可以使用Enumerate方法填充任何内容我最终使用了,但是我需要帮助弄清楚要使用什么。
Thanks. 谢谢。
(Note: This is the code posted in the comments) (注意:这是注释中发布的代码)
class Player
{
Statbook stats;
String name = "";
public Player(String n)
{
name = n;
stats = new Statbook();
}
public Statbook getStats()
{
return stats;
}
}
Use a HashSet inside the Team class to store all the players on the team: 在Team类中使用HashSet来存储团队中的所有球员:
class Team
{
private Set<Player> teamMembers = null;
public Team()
{
teamMembers = new HashSet<>();
}
public void addPlayer(Player p)
{
teamMembers.add(p);
}
//And so on...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.