static void Main(string[] args) { States states = new States(); MenuOrganizer menu = new MenuOrganizer(); Dictionary slownik = new Dictionary(); DictionaryManager manager = new DictionaryManager(slownik.words); //manager.addWord("Hi","Cześć"); //manager.addWord("Loop", "Pętla"); //manager.addWord("Run", "Biegać"); //manager.addWord("Retarded", "Niedorozwinięty"); //manager.addWord("Michael", "Michał" ); //manager.addWord("Wing", "Skrzydło"); menu.MenuLoop(states, manager); }
//Manages the menu as a state maschine public void MenuLoop ( States _state, DictionaryManager _dictionaryManager ) { Invoker invoker = new Invoker(); WordCommandFactory factory = new WordCommandFactory(_dictionaryManager); IStateCommand command = factory.GetCommand(_state); ConsoleKeyInfo keyinfo = Console.ReadKey(); while (_state != States.Exit) { this.DisplayMenu(); _state = States.idle; keyinfo = Console.ReadKey(); if (keyinfo.KeyChar == '0') { _state = States.import; } if (keyinfo.KeyChar == '1') { _state = States.translatePol2ang; } if (keyinfo.KeyChar == '2') { _state = States.translateAng2Pol; } if (keyinfo.KeyChar == '3') { _state = States.addWord; } if (keyinfo.KeyChar == '4') { _state = States.deleteWord; } if (keyinfo.KeyChar == '5') { _state = States.DisplayAll; } if (keyinfo.KeyChar == '6') { _state = States.Sort; } if (keyinfo.KeyChar == '7') { _state = States.BST; } if (keyinfo.KeyChar == '8') { _state = States.Exit; } Console.ReadKey(); this.ExecuteTask ( _state, command, factory, invoker ); Console.Clear(); } }