1 package org.enhydra.shark.wrd; 2 3 import java.io.Serializable ; 4 import java.util.*; 5 6 public class Participants extends HashMap implements Serializable , Cloneable { 7 8 public void addParticipant (String id) { 9 put(id,new Participant(id)); 10 } 11 12 public Participant getParticipant (String id) { 13 return (Participant)get(id); 14 } 15 16 public Participant theBestScoreParticipant () { 17 Participant theBest=null; 18 Iterator it=values().iterator(); 19 while (it.hasNext()) { 20 Participant p=(Participant)it.next(); 21 if (theBest==null) { 22 theBest=p; 23 continue; 24 } 25 if (p.getScore()>theBest.getScore()) { 26 theBest=p; 27 } 28 } 29 return theBest; 30 } 31 32 public Object clone () { 33 try { 34 Participants ps=(Participants)super.clone(); 35 ps.clear(); 36 Iterator it=this.entrySet().iterator(); 37 while (it.hasNext()) { 38 Map.Entry me=(Map.Entry)it.next(); 39 ps.put(me.getKey(),((Participant)me.getValue()).clone()); 40 } 41 return ps; 42 } catch (Exception ex) { 43 return null; 44 } 45 } 46 47 } 48 | Popular Tags |