void showLaps()
        {
            Driver driver = lbDrivers.SelectedItem as Driver;

            lbLaps.Items.Clear();
            if (driver != null && driver.Laps.Count > 0)
            {
                int limit = (int)nudLimit.Value;
                Lap best  = driver.Laps[0];
                foreach (Lap lap in driver.Laps)
                {
                    if (limit > 0)
                    {
                        if (lap.Time > limit)
                        {
                            lbLaps.Items.Add(lap);
                        }
                    }
                    else
                    {
                        lbLaps.Items.Add(lap);
                    }
                    if (lap.Time < best.Time)
                    {
                        best = lap;
                    }
                }
                tbBestLap.Text = best.ToString();
            }
            else
            {
                tbBestLap.Clear();
            }
        }
Example #2
0
        private void btnAddLap_Click(object sender, EventArgs e)
        {
            Driver d = lstDrivers.SelectedItem as Driver;
            Lap    l = new Lap(Convert.ToInt32(numMinutes.Value), Convert.ToInt32(numSeconds.Value));

            d.AddLap(l);
            loadLaps();
        }
Example #3
0
File: Form1.cs Project: AtanasK/VP
 private void btnAddLap_Click(object sender, EventArgs e)
 {
     Lap lap = new Lap();
     lap.Minutes = (int)nudMinutes.Value;
     lap.Seconds = (int)nudSeconds.Value;
     Driver driver = lbDrivers.SelectedItem as Driver;
     driver.Laps.Add(lap);
     nudMinutes.Value = 0;
     nudSeconds.Value = 0;
     showLaps();
 }
        private void btnAddLap_Click(object sender, EventArgs e)
        {
            Lap lap = new Lap();

            lap.Minutes = (int)nudMinutes.Value;
            lap.Seconds = (int)nudSeconds.Value;
            Driver driver = lbDrivers.SelectedItem as Driver;

            driver.Laps.Add(lap);
            nudMinutes.Value = 0;
            nudSeconds.Value = 0;
            showLaps();
        }
Example #5
0
 private void btnDodadiKrug_Click(object sender, EventArgs e)
 {
     if (lstVozaci.SelectedIndex != -1)
     {
         var vozac = lstVozaci.SelectedItem as Driver;
         Lap lap   = new Lap();
         lap.Minutes = Convert.ToInt32(nudMinuti.Value);
         lap.Seconds = Convert.ToInt32(nudSekundi.Value);
         vozac.Laps.Add(lap);
         RefreshValues();
         ClearValues();
     }
     else
     {
         string message = "Немате изберено возач!";
         string caption = "Неуспешно додавање круг";
         MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #6
0
        private void loadLaps()
        {
            Driver d = lstDrivers.SelectedItem as Driver;

            lstLaps.Items.Clear();
            if (d != null && d.Laps.Count > 0)
            {
                int limit         = (int)numTime.Value;
                Lap najdobar      = d.Laps[0];
                int najdobarVreme = najdobar.Minutes * 60 + najdobar.Seconds;
                foreach (object obj in d.Laps)
                {
                    Lap l      = obj as Lap;
                    int lVreme = l.Minutes * 60 + l.Seconds;
                    if (limit > 0)
                    {
                        if (najdobarVreme > limit)
                        {
                            lstLaps.Items.Add(l);
                        }
                    }
                    else
                    {
                        lstLaps.Items.Add(l);
                    }
                    if (najdobarVreme > lVreme)
                    {
                        najdobar = l;
                    }
                }
                tbNajbrz.Text = najdobar.ToString();
            }
            else
            {
                lstLaps.Items.Clear();
            }
            if (lstLaps.Items.Count == 0)
            {
                tbNajbrz.Text = null;
            }
        }
Example #7
0
    { /* @author: Damjan Miloshevski
       #contact:
       *    e-mail: [email protected]
       *    phone: +38978566409
       *    skype: damjan.milosevski
       */
        public Form1()
        {
            InitializeComponent();

            Driver l = new Driver("Lewis Hamilton", 28, true);
            Driver a = new Driver("Fernando Alonso", 32, false);
            Driver c = new Driver("Felipe Massa", 34, false);
            Driver u = new Driver("Kimi Raikonnen", 32, false);

            Lap l1 = new Lap(3, 45);
            Lap l2 = new Lap(2, 40);
            Lap l3 = new Lap(4, 22);

            l.AddLap(l1);
            l.AddLap(l2);
            l.AddLap(l3);

            Lap a1 = new Lap(2, 33);
            Lap a2 = new Lap(6, 55);

            a.AddLap(a1);
            a.AddLap(a2);

            Lap c1 = new Lap(2, 11);
            Lap c2 = new Lap(1, 45);

            c.AddLap(c1);
            c.AddLap(c2);

            Lap u1 = new Lap(1, 15);
            Lap u2 = new Lap(2, 45);

            u.AddLap(u1);
            u.AddLap(u2);

            lstDrivers.Items.Add(l);
            lstDrivers.Items.Add(a);
            lstDrivers.Items.Add(c);
            lstDrivers.Items.Add(u);
        }
Example #8
0
        private void ComputeBestLap(int secondsTreshold)
        {
            int minSeconds = Int32.MaxValue;
            Lap minLap     = null;

            foreach (Lap item in lstKrugovi.Items)
            {
                int lapSeconds = item.ToSeconds();
                if (lapSeconds > secondsTreshold && lapSeconds < minSeconds)
                {
                    minSeconds = lapSeconds;
                    minLap     = item;
                }
            }

            if (minLap != null)
            {
                txtNajdobar.Text = minLap.ToString();
            }
            else
            {
                txtNajdobar.Text = "";
            }
        }
Example #9
0
 public void AddLap(Lap l)
 {
     Laps.Add(l);
 }