I need a little conceptual help. I am trying to make a small baseball application. In baseball there is a depth chart which would have all the players of a team by position. I also need to create a lineup which would only be players at the top of their respective depth chart. how is the best (most efficient way) to go about it. My working solution i fear is primitive (I’m still pretty new so I’m sorry if its just useless)
What I have is:
private List<Player>[] depthChart = new ArrayList[9]; // 0 catcher, 1 pitcher, etc
private ArrayList<Player> lineup = new ArrayList<Player>(); // 0 of depthChart only
The game plan is to parse through the depthChart array and make sure only the first entry can go into the line up. I would have to build in constraints and logic to make sure you can’t have duplicates and make sure the lineup order is maintained. But I cant help thinking there is a better way.
I know this wont help all so if you want just ignore this. But if there are smarter people out there I would love some tips and guidance. You don’t need to to code for me. I just need to tips on how to approach this.
I’d try a
Map, where the key is a position enumeration and the value is aSetofPlayerswho can play the position. GivePlayeran ordinal value depth so you can sort by that.