예제 #1
0
        private void Nt_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (nt.Trip_Created)
            {
                currentTrip = nt.Current_Trip;

                // check if the fuel is empty  >> if then take $100 from current net income, and add fuel ($ 20)
                if (currentTM.Fuel - currentTrip.Fuel <= 0)
                {
                    currentTM.NetIncome -= 100.00;
                    // create random price for the fuel
                    Random rnd          = new Random();
                    int    random       = rnd.Next(15, 45);
                    string price        = "1." + random.ToString();
                    double random_price = Convert.ToDouble(price);
                    MessageBox.Show("You have called a recharging service. You have spent $100(Service fee) and $50(Fuel charge).\nPrice for Fuel was :  $ " + price + " / liter");
                    currentTM.TaxiMeter_Renew(currentTM, currentTrip);
                    currentTM.Add_Fuel(random_price, 50.00, currentTM);
                    TaxiMeter_Reload(currentTM);
                }
                else
                {
                    // add current trip to the current taxi meter
                    currentTM.TaxiMeter_Renew(currentTM, currentTrip);
                    TaxiMeter_Reload(currentTM);
                }
            }
            nt = null;
        }
예제 #2
0
 private void btn_newtrip_Click(object sender, EventArgs e)
 {
     if (nt == null)
     {
         nt              = new NewTrip();
         nt.FormClosing += Nt_FormClosing;
         nt.Show();
     }
 }