Java Reference
In-Depth Information
First, you need to define a set of attributes that each team needs to contain. To do
this, a Java interface should be created, containing the different attributes that need to
be applied to each team object. The following is an example of such an interface:
public interface TeamType {
public void setPlayers(List<Player> players);
public void setName(String name);
public void setCity(String city);
public String getFullName();
}
Next, define a class to represent a team. This class needs to implement the
TeamType interface that was just created so that it will adhere to the format that is re-
quired to build a team:
public class Team implements TeamType {
private List<Player> players;
private String name = null;
private String city = null;
private int wins = 0;
private int losses = 0;
private int ties = 0;
/**
* @return the players
*/
public List<Player> getPlayers() {
return players;
}
/**
* @param players the players to set
*/
public void setPlayers(List<Player> players) {
this.players = players;
}
Search WWH ::




Custom Search