All pastes #390947 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-03-11 20:07 UTC
rendered paste body

/**
 * Write a description of class Score here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 * new String ("Tanner,1,2,3,4,5,6");
 */
public class Score
{
    public String nick;
    public int gamesPlayed, gamesWon, gamesLost, rocksThrown, papersThrown, scissorsThrown;
    
    public Score(String line)
    {
        nick = line.substring (0, line.indexOf(","));
        int from = line.indexOf(",", line.indexOf(",") + 1);
        gamesPlayed = Integer.parseInt(line.substring (line.indexOf(",") + 1, from));
        from = line.indexOf(",", from);    
        gamesWon = Integer.parseInt(line.substring (line.indexOf(",", from), from));
        from = line.indexOf(",", from);
        gamesLost = Integer.parseInt(line.substring (line.indexOf(",") + 1, from));
        from = line.indexOf(",", from);
        rocksThrown = Integer.parseInt(line.substring (line.indexOf(",") + 1, from));
        from = line.indexOf(",", from);
        papersThrown = Integer.parseInt(line.substring (line.indexOf(",") + 1, from));
        from = line.indexOf(",", from);
        scissorsThrown = Integer.parseInt(line.substring (line.indexOf(",") + 1, from));
        from = line.indexOf(",", from);
        System.out.println (this);
    }
    
    public String toString ()
    {
        return nick + "," + gamesPlayed + "," + gamesWon + "," + gamesLost + "," + rocksThrown + "," 
                + papersThrown + "," + scissorsThrown;
    }
}