private void Submit_Click(object sender, EventArgs e) { Tower.clear(); int length = (int)numericUpDown1.Value; int i = 0; do { int temp = rnd.Next(1, 101); if (Tower.checksizes(temp) == false) { Pancake pancake = new Pancake(temp); Tower.addpancake(pancake); } else { i--; } i++; } while (i < length); string msg = Tower.sort(); MessageBox.Show(msg); }
public string sort() { for (int i = 0; i < pancakes.Count; i++) { for (int j = i + 1; j < pancakes.Count; j++) { if (pancakes[i].Radius > pancakes[j].Radius) { Pancake temp = pancakes[i]; pancakes[i] = pancakes[j]; pancakes[j] = temp; } } } string build = ""; foreach (var item in pancakes) { build += item.Radius.ToString() + ","; } return(build); }
public void addpancake(Pancake pancake) { pancakes.Add(pancake); }