//********************************************************************************

//Katherine C

//Athlete parent class

//2-26-09

//********************************************************************************

public class Athlete

{

private String name, sport;

private double height, weight;

private int numWins;

public Athlete (String n, String s, double h, double w)

{

name = n;

sport = s;

height = h;

weight = w;

numWins = 0;

}

public void win ()

{

numWins ++;

}

public void changeSport (String newSport)

{

sport = newSport;

}

public String toString ()

{

return "Name: " + name + "\nSport: " + sport + "\nHeight: " + height +

"\nWeight: " + weight + "\nNumber of Wins: " + numWins;

}

}

// ***** end Athlete

//********************************************************************************

//Katherine C

//Soccer Player (Athlete sub-class)

//2-26-09

//********************************************************************************

public class SoccerPlayer extends Athlete

{

private String position, team;

private int jersey, numPoints;

public SoccerPlayer (String n, double h, double w, String p, String t, int j)

{

super (n, "Soccer", h, w);

position = p;

team = t;

jersey = j;

numPoints = 0;

}

public void score ()

{

numPoints ++;

}

public void changeSpot (String newSpot)

{

position = newSpot;

}

public void changeTeam (String newTeam, int newJersey)

{

team = newTeam;

jersey = newJersey;

}

public String toString ()

{

return super.toString() + "\nTeam: " + team + "\nPosition: " + position

+ "\nJersey number: " + jersey + "\nCareer Points: " + numPoints;

}

}

// **** end SoccerPlayer

//********************************************************************************

//Katherine C

//Driver for SoccerPlyer class

//2-26-09

//********************************************************************************

public class SoccerPlayerDriver

{

public static void main (String[]args)

{

SoccerPlayer helen;

helen = new SoccerPlayer ("Helen", 5.0, 120.0, "Midfield", "HBMS", 10);

sop ("Here is a new soccer player.");

System.out.println (helen);

for (int i = 0; i < 5; i ++)

helen.score();

helen.win();

helen.changeTeam ("Centennial High School", 5);

sop ("\n\n");

sop ("Helen has now scored five goals, won a game, and changed teams.");

System.out.println (helen);

}

public static void sop(String print)

{

System.out.println (print);

}

}

// **** end SoccerDriver

/*Output:

------Configuration: <Default>------

Here is a new soccer player.

Name: Helen

Sport: Soccer

Height: 5.0

Weight: 120.0

Number of Wins: 0

Team: HBMS

Position: Midfield

Jersey number: 10

Career Points: 0

Helen has now scored five goals, won a game, and changed teams.

Name: Helen

Sport: Soccer

Height: 5.0

Weight: 120.0

Number of Wins: 1

Team: Centennial High School

Position: Midfield

Jersey number: 5

Career Points: 5

Process completed.

*/