private void reload() { lsKids.Items.Clear(); swdata.moveFirst(); while (swdata.hasMoreElements()) { Swimmer sw = swdata.getSwimmer(); lsKids.Items.Add(sw.getName()); } }
private void btClone_Click(object sender, System.EventArgs e) { SexSwimData newSd = (SexSwimData)swdata.Clone(); newSd.sort(opFemale.Checked); lsNewKids.Items.Clear(); while (newSd.hasMoreElements()) { Swimmer sw = (Swimmer)newSd.getSwimmer(); lsNewKids.Items.Add(sw.getName()); } }
private void btClone_Click(object sender, System.EventArgs e) { AgeSwimData newSd = new AgeSwimData(); newSd.cloneMe(swdata); newSd.sort(); lsNewKids.Items.Clear(); while (newSd.hasMoreElements()) { Swimmer sw = (Swimmer)newSd.getSwimmer(); lsNewKids.Items.Add(sw.getName()); } }
public void sort(bool isFemale) { ArrayList swd = new ArrayList(); for (int i = 0; i < swdata.Count; i++) { Swimmer sw = (Swimmer)swdata[i]; if (isFemale == sw.isFemale()) { swd.Add(sw); } } swdata = swd; }
//----- public SwimData(string filename) { swdata = new ArrayList(); csFile fl = new csFile(filename); fl.OpenForRead(); string s = fl.readLine(); while (s != null) { Swimmer sw = new Swimmer(s); swdata.Add(sw); s = fl.readLine(); } fl.close(); }
public override void sort() { Swimmer[] sws = new Swimmer[swd.Count]; //copy in swimmer objects for (int i = 0; i < swd.Count; i++) { sws[i] = (Swimmer)swd[i]; } //sort into increasing order for (int i = 0; i < sws.Length; i++) { for (int j = i; j < sws.Length; j++) { if (sws[i].getAge() > sws[j].getAge()) { Swimmer sw = sws[i]; sws[i] = sws[j]; sws[j] = sw; } } } int age = sws[0].getAge(); int agecount = 0; int k = 0; swdata = new ArrayList(); bool quit = false; while (k < sws.Length && !quit) { while (sws[k].getAge() == age && !quit) { agecount++; if (k < sws.Length - 1) { k++; } else { quit = true; } } //create a new Swimmer with a series of X's for a name //for each new age string name = ""; for (int j = 0; j < agecount; j++) { name += "X"; } Swimmer sw = new Swimmer(age.ToString() + " " + name + "," + age.ToString() + ",club,0,F"); swdata.Add(sw); agecount = 0; if (quit) { age = 0; } else { age = sws[k].getAge(); } } }
//--------- public int CompareTo(object swo) { Swimmer sw = (Swimmer)swo; return(lname.CompareTo(sw.getLName())); }