- #1
kirkulator
- 33
- 0
<indent>
I have a class for soccer players with these attributes:
//players first name
private firstName;
//players lastName
private lastName;
//number of points scored by player
private int pointsScored = 0;
//number of assists the player had
private int assists = 0;
//the percentage kick penalty rate the player had
private double penaltyKickRate = 0.0;
i am assigned to have a constructor with a single formatted string parameter like this:
public SoccerPlayerStats(String playerinfo) {
//initialize values
}
where the playerinfo string is formatted this way
"Jane Doe: Points Scored: 3 Assists: 5 Kick Rate Percentage: 3"
how in the world can i initialize these values in the contructor? With substrings maybe? It just seems a little wacky to me. Any tips will help : )
- Amanda
</indent>
I have a class for soccer players with these attributes:
//players first name
private firstName;
//players lastName
private lastName;
//number of points scored by player
private int pointsScored = 0;
//number of assists the player had
private int assists = 0;
//the percentage kick penalty rate the player had
private double penaltyKickRate = 0.0;
i am assigned to have a constructor with a single formatted string parameter like this:
public SoccerPlayerStats(String playerinfo) {
//initialize values
}
where the playerinfo string is formatted this way
"Jane Doe: Points Scored: 3 Assists: 5 Kick Rate Percentage: 3"
how in the world can i initialize these values in the contructor? With substrings maybe? It just seems a little wacky to me. Any tips will help : )
- Amanda
</indent>