I am having troubles getting my head wrapped around how this should be done. I have 3 check boxes on a form that are to be input into a constructor. I am creating a variable to pass this information into the constructor. Listed below some of the code
public enum Accessories
{
None,
StereoSystem,
LeatherInterior,
StereoAndLeather,
ComputerNavigation,
StereoAndNavigation,
LeatherAndNavigation,
All
}
SalesQuote.Accessories accessoryChosen;
if(!chkStereoSystem.Checked && !chkLeatherInterior.Checked && !chkComputerNavigation.Checked)
{
accessoryChosen = SalesQuote.Accessories.None;
}
else if(chkStereoSystem.Checked && !chkLeatherInterior.Checked && !chkComputerNavigation.Checked)
{
accessoryChosen = SalesQuote.Accessories.StereoSystem;
}
Am sure there is an much cleaner way to do this.
Aucun commentaire:
Enregistrer un commentaire