1 25 package org.objectweb.speedo.pobjects.detach; 26 27 import java.util.ArrayList ; 28 import java.util.Collection ; 29 import java.util.Iterator ; 30 33 public class Team { 34 35 protected String town; 36 protected Collection players; 37 protected Coach coach; 38 39 public Team(String town, Collection players, Coach coach){ 40 this.town = town; 41 this.players = (players == null)?new ArrayList ():players; 42 this.coach = coach; 43 } 44 45 public Coach getCoach() { 46 return coach; 47 } 48 49 public Collection getPlayers() { 50 return players; 51 } 52 53 public String getTown() { 54 return town; 55 } 56 57 public void setCoach(Coach coach) { 58 this.coach = coach; 59 } 60 61 public void setPlayers(Collection collection) { 62 players = collection; 63 } 64 65 public void addPlayer(Player p){ 66 players.add(p); 67 } 68 69 public void setTown(String string) { 70 town = string; 71 } 72 73 public String toString(){ 74 String s = "Team[" + town + ", " + ((coach!=null)?coach.toString():"no coach") + ", "; 75 Iterator it = players.iterator(); 76 while(it.hasNext()){ 77 Player p = (Player) it.next(); 78 s += p.toString() + " "; 79 } 80 s+= " ]"; 81 return s; 82 } 83 } 84 | Popular Tags |