public Form1() { InitializeComponent(); Buss bus = new Buss("5463", "JSP 5", true); bus.AddDestination(new Line("Aerodrom", 12, 5, 35)); lbBus.Items.Add(bus); loadLines(); }
void loadLines() { lbLines.Items.Clear(); tbAverage.Clear(); tbExpensive.Clear(); Buss bus = lbBus.SelectedItem as Buss; if (bus != null && bus.Lines.Count > 0) { Line maxPrice = bus.Lines[0]; float totalPrice = 0; foreach (Line line in bus.Lines) { lbLines.Items.Add(line); if (line.Price > maxPrice.Price) { maxPrice = line; } totalPrice += line.Price; } tbAverage.Text = string.Format("{0:#.0}", totalPrice / lbLines.Items.Count); tbExpensive.Text = maxPrice.ToString(); } }
private void btnSave_Click(object sender, EventArgs e) { bus = new Buss(tbRegistration.Text.Trim(), tbName.Text.Trim(), cbLocal.Checked); DialogResult = System.Windows.Forms.DialogResult.OK; }