1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Constructor with a string paramater?

  1. Nov 6, 2011 #1
    <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>
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?



Similar Discussions: Constructor with a string paramater?
Loading...