private static void VehicleSample() { VehicleList vehicles = new VehicleList(); SingleVehicle singleVehicle; MenuCls commonMenuCls, chooseVehicleMenuCls; foreach (IVehicle item in vehicles) { item.Stop(); } Console.ReadLine(); Console.Clear(); List<MenuItem> chooseVehicleMenuItems = new List<MenuItem>(); chooseVehicleMenuItems.Add(new MenuItem(1, "Auto.", new CommonDel(() => { singleVehicle = new SingleVehicle(new Avto()); singleVehicle.ShowMenu(); }))); chooseVehicleMenuItems.Add(new MenuItem(2, "Bus.", new CommonDel(() => { singleVehicle = new SingleVehicle(new Bus()); singleVehicle.ShowMenu(); }))); chooseVehicleMenuItems.Add(new MenuItem(3, "Moto.", new CommonDel(() => { singleVehicle = new SingleVehicle(new Moto()); singleVehicle.ShowMenu(); }))); chooseVehicleMenuItems.Add(new MenuItem(4, "TrolleyBus.", new CommonDel(() => { singleVehicle = new SingleVehicle(new TrolleyBus()); singleVehicle.ShowMenu(); }))); chooseVehicleMenuItems.Add(new MenuItem(5, "Truck.", new CommonDel(() => { singleVehicle = new SingleVehicle(new Truck()); singleVehicle.ShowMenu(); }))); chooseVehicleMenuCls = new MenuCls("Choose Vehicle", chooseVehicleMenuItems); List<MenuItem> commonMenuItems = new List<MenuItem>(); commonMenuItems.Add(new MenuItem(1, "Start AutoDrive.", new CommonDel(vehicles.StartDriving))); commonMenuItems.Add(new MenuItem(2, "Drive single vehicle.", new CommonDel(chooseVehicleMenuCls.ShowMenu))); commonMenuCls = new MenuCls("Vehicle Menu", commonMenuItems); commonMenuCls.ShowMenu(); }
static void Main(string[] args) { int command = 0; HomeWork4 hw4 = new HomeWork4(); MenuCls menu = new MenuCls(); do { command = menu.ShowMenu(hw4); } while (command != 0); }
//public static delegate void MyDel(); static void Main(string[] args) { Class1 cls = new Class1(); List<string> menuItems = new List<string>(); Dictionary<int, MenuItem> MyDict = new Dictionary<int, MenuItem>(); MyDict.Add(1, new MenuItem("DELETE ZERO.", new CommonDel(cls.DeleteZero))); MyDict.Add(2, new MenuItem("SORT.", new CommonDel(cls.Sort))); MyDict.Add(3, new MenuItem("COMPARE.", new CommonDel(cls.Compare))); MyDict.Add(4, new MenuItem("CHANGE COLUMNS.", new CommonDel(cls.ChangeColumns))); MyDict.Add(5, new MenuItem("GET STATISTICS.", new CommonDel(cls.StringStatistic))); MyDict.Add(6, new MenuItem("MODIFY STRING.", new CommonDel(cls.ModifyString))); MenuCls menuCls = new MenuCls("My Menu", MyDict); menuCls.ShowMenu(); }
static void Main(string[] args) { List<string> menuItems = new List<string>(); Dictionary<int, MenuItem> MyDict = new Dictionary<int, MenuItem>(); MyDict.Add(1, new MenuItem("Line Eq.", new CommonDel(LineMethod))); MyDict.Add(2, new MenuItem("Compare Cities.", new CommonDel(CityCompare))); MyDict.Add(3, new MenuItem("Fraction.", new CommonDel(Fraction))); MyDict.Add(4, new MenuItem("Complex.", new CommonDel(Complex))); MyDict.Add(5, new MenuItem("Sort Cities.", new CommonDel(SortCities))); MenuCls menuCls = new MenuCls("My Menu", MyDict); menuCls.ShowMenu(); }