c# - Am I missing an if statement? -


thanks in advance help!

a bit of background building application stores vehicles (cars,truck,buses), have vehicle superclass , individual classes (car.cs, truck.cs, minibus.cs) inherit super class.

i have class called 'fleet' add vehicles display results in list box.

i have else working cannot trucks , minibus's update , display on list box cars do.

here fleet class includes car.cs; , works fine , data taken car form gets added , displayed in listbox.

class fleet {     private list<vehicle> thefleet = new list<vehicle>();       public list<vehicle> fleet      {                 {             return thefleet;         }     }      public void deletefromfleet(vehicle acar)     {         thefleet.remove(acar);     }      public void addtofleet(vehicle acar)     {         thefleet.add(acar);     } } 

here main form, has list box on it:

public partial class frmhireco : form {     private fleet myfleet = new fleet();     private clientlist mycustomer = new clientlist();      //fleet object used store cars      public frmhireco()     {         //default constructor         initializecomponent();                     }              private void updatefleetlist()     {            lstfleet.items.clear();         foreach (car c in myfleet.fleet)         {             string line = "car: " + c.make+" " + c.colour;             lstfleet.items.add(line);         }     }      private void updateclientlist()     {            customers.items.clear();         foreach (customer c in mycustomer.clientlist)         {             string line = "customer: " + c.name + " " + c.address;             customers.items.add(line);         }     }      private void btnaddcar_click(object sender, eventargs e)     {         //add new car         frmcar cargui = new frmcar(); //form used add new car         cargui.showdialog();         car mycar = cargui.car;         //get new car form         myfleet.addtofleet(mycar);      //add fleet list         updatefleetlist();              //uodate fleet list     }      private void lstfleet_selectedindexchanged(object sender, eventargs e)     {         if (lstfleet.selectedindex > -1)         {             int index = lstfleet.selectedindex;             car mycar = myfleet.fleet.elementat(index);             frmcar cargui = new frmcar();             cargui.car = mycar;             cargui.show();         }     }      private void btncustomer_click(object sender, eventargs e)     {         frmcustomer customergui = new frmcustomer();         customergui.showdialog();         customer mycustomer = customergui.customer;                  mycustomer.addtoclientlist(mycustomer);               updatefleetlist();     }      private void customers_selectedindexchanged(object sender, eventargs e)     {         if (customers.selectedindex > -1)         {             int index = customers.selectedindex;             customer mycustomer = mycustomer.clientlist.elementat(index);             frmcustomer customergui = new frmcustomer();             customergui.customer = mycustomer;             customergui.show();         }     } } 

cheers help!

private void updatefleetlist()     {            lstfleet.items.clear();         foreach (vehicle c in myfleet.fleet)         {             string line = "car: " + c.make+" " + c.colour;             lstfleet.items.add(line);         }     } 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -