Closed CelticMajora closed 9 years ago
I'll need you to parse out first and last names, should be easy with an 'indexOf()' and some 'substring()'. I'm staying generic with names being names everywhere so others don't need to recombine the two halves.
To get the first name out of String name = "John Doe"
:
String firstName = name.substring(0, name.indexOf(" "));
To get the last name out of the same string above:
String lastName = name.substring(name.indexOf(" ") + 1);
Keep in mind that, as far as I know, no data will get added for injuries for our game's data as no injuries occurred. Nonetheless, for our game-generic approach your module still has purpose, and can still be tested if we add artificial data!
For the methods I'm writing for your data, you are going to be returned an int[][], a String[][], and a String[][] for the 'games missed', 'type', and 'location' fields respectively. For each, go one level deep with an index indicative of the player. The subindex corresponds to the respective injury (some players might receive multiple injuries).
Okay, you might need to explain that to me a little bit in class. I believe that I sort of understand.
Would people with no injuries have null in their array spots?
That's my understanding, aye... if I follow the JSON Java documentation correctly, making calls on nonexistent data will return null. Let me know if that doesn't work out once your code has gotten the data methods built in. I plan on helping everybody with the data methods tomorrow, they seem to be properly completed.
Here are each of the relevant examples for your data's parallel structure..
Each Team's Players' Names: String[] teamAPlayersNames = data.teamPlayersNames(true); String[] teamBPlayersNames = data.teamPlayersNames(false);
player index | 0 | 1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|---|---|
name | Rodriguez Man | Dork Example | Shmuck Hitter | Mad Batter | Crazy Sam | Smiley Face |
Each Team's Players' Injuries' Games Missed: int[][] teamAPlayersInjuriesGamesMissed = data.teamPlayersInjuriesGamesMissed(true); int[][] teamBPlayersInjuriesGamesMissed = data.teamPlayersInjuriesGamesMissed(false);
player index | 0 | 1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|---|---|
injury indeces | null | {0, 1} | null | {0} | null | null |
gamesMissed | null | {3, 1} | null | {1} | null | null |
Each Team's Players' Injuries' Types: String[][] teamAPlayersInjuriesTypes = data.teamPlayersInjuriesTypes(true); String[][] teamBPlayersInjuriesTypes = data.teamPlayersInjuriesTypes(false);
player index | 0 | 1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|---|---|
injury indeces | null | {0, 1} | null | {0} | null | null |
type | null | {"burned", "broke"} | null | {"tore"} | null | null |
Each Team's Players' Injuries' Locations: String[][] teamAPlayersInjuriesLocations = data.teamPlayersInjuriesLocations(true); String[][] teamBPlayersInjuriesLocations = data.teamPlayersInjuriesLocations(false);
player index | 0 | 1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|---|---|
injury indeces | null | {0, 1} | null | {0} | null | null |
type | null | {"nose", "knee"} | null | {"buttock"} | null | null |
int timeOut = // # of games player will be out for
String first = // player's first name
String last = // player's last name
String type = // type of injury in past tense, like burned or broke or tore
String location = // where the injury is on the body, for example, nose or knee.