public int AddNewHero() { var addNewHeroMenu = _actionService.GetMenuActionsByMenuName("CreateHero"); int typeId; int lastTypeId = addNewHeroMenu.OrderBy(o => o.Id).LastOrDefault().Id; int lastId = _heroService.GetLastId(); Console.WriteLine("\nYou are current in menu \"Add Hero\". If you want go back press -1 else press enter"); int goBack = EnterValue(Console.ReadLine()); if (goBack == -1) { return(0); } typeId = ReturnProperlyEnteredTypeId(); string name = ReturnProperlyEnteredName(typeId); Console.WriteLine($"\nYou can cancel adding Hero {name} {addNewHeroMenu[typeId - 1].Name} by pressing -1"); goBack = EnterValue(Console.ReadLine()); if (goBack == -1) { Console.WriteLine("You canceled adding Hero"); return(0); } var hero = new Hero(lastId + 1, name, GetHeroInitialStats(addNewHeroMenu[typeId - 1].Name, "health"), GetHeroInitialStats(addNewHeroMenu[typeId - 1].Name, "attack"), addNewHeroMenu[typeId - 1].Name, typeId); _heroService.AddObject(hero); return(hero.Id); }
public void ShowMainMenu() { Console.WriteLine("Hello! Welcome to MusicReco App!\r\n"); Console.WriteLine("What do you want to do?"); var mainMenu = _menuActionService.GetMenuActionsByMenuName("Main"); foreach (var menuAction in mainMenu) { Console.WriteLine($"{menuAction.Id}. {menuAction.ActionName}"); } Console.Write("Enter the number: "); }
public void CanGetMenuActionsByMenuName() { List <MenuAction> listOfMenuActions1 = new List <MenuAction>(); List <MenuAction> listOfMenuActions2 = new List <MenuAction>(); MenuActionService menuActionService = new MenuActionService(); listOfMenuActions1 = menuActionService.GetMenuActionsByMenuName("Login"); listOfMenuActions2 = menuActionService.GetMenuActionsByMenuName("mainMenu"); listOfMenuActions1.Count.Should().Equals(2); listOfMenuActions2.Count.Should().Equals(7); }
public int AddNewItem() { int userDecision = 1; var addNewItemMenu = _actionService.GetMenuActionsByMenuName("AddNewItemMenu"); Console.WriteLine("Please select recipe type: "); foreach (var item in addNewItemMenu) { Console.WriteLine($"{item.Id}. {item.Name}"); } var operation = Console.ReadKey(); int typeOfMeal; Int32.TryParse(operation.KeyChar.ToString(), out typeOfMeal); Console.Write("Name: "); var name = Console.ReadLine(); Console.WriteLine("Please enter ingredients for new recipe: "); List <string> recipeIngrediens = new List <string>(); recipeIngrediens.Add(Console.ReadLine()); while (userDecision != 0) { Console.Write("Do you want add more ingredients? Type 1(yes) or 0(no): "); var decision = Console.ReadLine(); Int32.TryParse(decision, out userDecision); if (userDecision == 1) { recipeIngrediens.Add(Console.ReadLine()); } else if (userDecision == 0) { break; } else { Console.WriteLine("This action doesn't exists"); } } Console.WriteLine("Please enter actions (what must be done in the recipe): "); var actionsRecipe = Console.ReadLine(); var lastId = _recipeService.GetLastId(); Recipe newRecipe = new Recipe(lastId + 1, name, recipeIngrediens, actionsRecipe, typeOfMeal); _recipeService.AddItem(newRecipe); return(newRecipe.Id); }
public void CantGetMenuByBadCategory() { var menuActionService = new MenuActionService(); var mainMenu = menuActionService.GetMenuActionsByMenuName("Game"); mainMenu.Should().BeEmpty(); mainMenu.Should().BeOfType(typeof(List <MenuAction>)); }
static void Main(string[] args) { MenuActionService actionService = new MenuActionService(); IService <Item> itemService = new ItemService(); ItemManager itemManager = new ItemManager(actionService, itemService); //Welcome User Console.WriteLine("Welcome to the Collection Manager!"); while (true) { //Giving user a choice what to do next Console.WriteLine("\r\nPlease, choose your next action:"); var mainMenu = actionService.GetMenuActionsByMenuName("Main"); for (int i = 0; i < mainMenu.Count; i++) { Console.WriteLine($"{mainMenu[i].Id}. {mainMenu[i].Name}"); } var operation = Console.ReadKey(); //Proccessing users decision switch (operation.KeyChar) { case '1': var item = itemManager.CreateItem(); itemManager.AddItem(item); break; case '2': var itemToRemove = itemManager.ChooseRemoveItem(); itemManager.RemoveItem(itemToRemove); break; case '3': itemManager.EditExistingItem(); break; case '4': var typeId = itemManager.GetItemsTypeId(); var toShow = itemManager.GetItemsOfTheSameType(typeId); if (toShow.Any()) { itemManager.ShowItemsOfSameType(toShow); } else { Console.WriteLine("\r\nCollection is empty"); } break; default: Console.WriteLine("\r\nAction you entered does not exist"); break; } } }
public void CanGetMenuByCategory() { var menuActionService = new MenuActionService(); var mainMenu = menuActionService.GetMenuActionsByMenuName("Main"); mainMenu.Should().NotBeEmpty(); mainMenu.Should().NotBeNull(); mainMenu.Should().BeOfType(typeof(List <MenuAction>)); }
public void Should_GetEmptyList_When_GivenEmptyString() { //Arrange MenuActionService menuActionService = new MenuActionService(); //Act List <MenuAction> result = menuActionService.GetMenuActionsByMenuName(""); //Assert result.Should().BeEmpty(); }
public int ChooseDifficultyLevel() { var difficultyLevelMenu = _actionService.GetMenuActionsByMenuName("DifficultyLevel"); int diffLvl; int diffLvlMax = difficultyLevelMenu.OrderBy(o => o.Id).LastOrDefault().Id; do { Console.WriteLine("\nPlease select difficulty level:"); ShowMenuAction(difficultyLevelMenu); diffLvl = EnterValue(Console.ReadKey().KeyChar.ToString()); Console.WriteLine(); if (diffLvl < 1 || diffLvl > diffLvlMax) { Console.WriteLine("\nBad Type difficulty level"); } }while (diffLvl < 1 || diffLvl > diffLvlMax); return(diffLvl); }
public Item CreateItem() { var ItemTypeMenu = _actionService.GetMenuActionsByMenuName("ItemTypeMenu"); Console.WriteLine("\r\nSelect collection item type:"); for (int i = 0; i < ItemTypeMenu.Count; i++) { Console.WriteLine($"{ItemTypeMenu[i].Id}. {ItemTypeMenu[i].Name}"); } var operation = Console.ReadKey(); int typeId; Int32.TryParse(operation.KeyChar.ToString(), out typeId); Console.WriteLine("\r\nEnter name of new item:"); var name = Console.ReadLine(); Console.WriteLine("\r\nEnter description of new item:"); var desc = Console.ReadLine(); if (desc == null) { desc = "No description"; } Console.WriteLine("\r\nEnter value of new item:"); var value = Console.ReadLine(); decimal itemValue; Decimal.TryParse(value, out itemValue); var lastId = _itemService.GetLastId(); Item item = new Item(lastId + 1, name, typeId) { Description = desc, Value = itemValue }; return(item); }
static void Main(string[] args) { MenuActionService actionService = new MenuActionService(); RecipeManager itemManager = new RecipeManager(actionService); while (true) { Console.Clear(); Console.WriteLine("Welcome in my cookBook. What do you want to do?: "); var mainMenu = actionService.GetMenuActionsByMenuName("Main"); foreach (var item in mainMenu) { Console.WriteLine($"{item.Id}. {item.Name}"); } var operation = Console.ReadKey(); Console.WriteLine(); switch (operation.KeyChar) { case '1': var newId = itemManager.AddNewItem(); break; case '2': itemManager.ShowItem(); break; case '3': var removeId = itemManager.RemoveItem(); break; case '4': itemManager.randomRecipe(); break; case '5': Environment.Exit(0); break; default: Console.WriteLine("Something went wrong... This action doesn't exists."); break; } } }
public int FundsMenuView() { var fundsMenu = _actionService.GetMenuActionsByMenuName("FundsMenu"); Console.WriteLine("Fundusze."); for (int i = 0; i < fundsMenu.Count; i++) { Console.WriteLine($"{fundsMenu[i].Id}. {fundsMenu[i].Name}"); } System.Console.WriteLine(); string readedOperation = Console.ReadLine(); int operation; Int32.TryParse(readedOperation, out operation); System.Console.WriteLine(); return(operation); }
public int HomeBudgetMenuView(MenuActionService actionService) { var homeBudgetMenu = actionService.GetMenuActionsByMenuName("HomeBudgetMenu"); Console.WriteLine("Budżet domowy."); for (int i = 0; i < homeBudgetMenu.Count; i++) { Console.WriteLine($"{homeBudgetMenu[i].Id}. {homeBudgetMenu[i].Name}"); } System.Console.WriteLine(); string readedOperation = Console.ReadLine(); int operation; Int32.TryParse(readedOperation, out operation); System.Console.WriteLine(); return(operation); }
public int DungeonMenu(MenuActionService actionService) { List <MenuAction> dungeonMenu = actionService.GetMenuActionsByMenuName("Dungeon"); int selectedOption; Console.WriteLine("What do you want to do in this dungeon:"); Console.WriteLine(); for (int i = 0; i < dungeonMenu.Count; i++) { Console.WriteLine($"{dungeonMenu[i].Id}. {dungeonMenu[i].Name}"); } var readedKey = Console.ReadKey(); Int32.TryParse(readedKey.KeyChar.ToString(), out selectedOption); return(selectedOption); }
public int AddNewExercise() { var addNewExerciseMenu = _actionService.GetMenuActionsByMenuName("AddNewExerciseMenu"); var menuActionsToShow = new List <string>(); addNewExerciseMenu.ForEach(menuAction => menuActionsToShow.Add($"{menuAction.Id}. {menuAction.Name}")); _informationProvider.ShowMultipleInformation(menuActionsToShow); bool isValidInput = false; int typeId = 0; while (!isValidInput) { _informationProvider.ShowSingleMessage("Please select exercise type:"); typeId = _informationProvider.GetNumericInputKey(); isValidInput = typeId != 0 && typeId <= menuActionsToShow.Count; } isValidInput = false; string name = string.Empty; while (!isValidInput) { _informationProvider.ShowSingleMessage("\nPlease insert name for item: "); name = _informationProvider.GetInputString(); isValidInput = !string.IsNullOrWhiteSpace(name); } var lastId = _exerciseService.GetLastId(); var exercise = new Exercise(lastId + 1, name, typeId); _exerciseService.AddItem(exercise); return(exercise.Id); }
static void Main(string[] args) { MenuActionService actionService = new MenuActionService(); ItemService itemService = new ItemService(); ItemMenager itemMenager = new ItemMenager(actionService, itemService); Console.WriteLine("Witaj!!!"); while (true) { Console.WriteLine("Wwybierz co chcesz zrobić z plikiem"); var mainMenu = actionService.GetMenuActionsByMenuName("Main"); for (int i = 0; i < mainMenu.Count; i++) { Console.WriteLine($"{mainMenu[i].Id}. {mainMenu[i].Name}"); } var operation = Console.ReadKey(); Console.Clear(); switch (operation.KeyChar) { case '1': itemMenager.AddNewItem(); break; case '2': itemMenager.RemoveItem(); break; case '3': itemMenager.ItemsByTypeIdView(); break; case '4': //var typeId = itemService.ItemTypeSeleCtionView(); //itemService.ItemsByTypeIdView(typeId); //break; default: Console.WriteLine("nieprawidłowa akcja!!"); break; } } }
//public void AddNewItem() //{ // var addNewItemMenu = _actionService.GetMenuActionsByMenuName("AddNewItemMenu"); // Console.WriteLine("Wybierz typ pliku:"); // for (int i = 0; i < addNewItemMenu.Count; i++) // { // Console.WriteLine($"{addNewItemMenu[i].Id}. {addNewItemMenu[i].Name}"); // } // int lastId = _itemService.GetLastId(); // var operation = Console.ReadKey(); // Int32.TryParse(operation.KeyChar.ToString(), out int typeId); // Console.WriteLine("Podaj nazwe pliku:"); // var name = Console.ReadLine(); // Item item = new Item(lastId+1,name.ToString(), typeId); // Items.Add(item); //} public int AddNewItem() { var addNewItemMenu = _actionService.GetMenuActionsByMenuName("AddNewItemMenu"); Console.WriteLine("Podaj typ pliku:"); for (int i = 0; i < addNewItemMenu.Count; i++) { Console.WriteLine($"{addNewItemMenu[i].Id}. {addNewItemMenu[i].Name}"); } var operation = Console.ReadKey(); int typeId; Int32.TryParse(operation.KeyChar.ToString(), out typeId); Console.WriteLine("Podaj nazqwe pliku:"); var name = Console.ReadLine(); var lastId = _itemService.GetLastId(); Item item = new Item(lastId + 1, name, typeId); _itemService.AddItem(item); return(item.Id); }
public void Should_GetMenuActions_When_GivenMenuName() { //Arrange MenuAction menuAction1 = new MenuAction(1, "Check it", "Test"); MenuAction menuAction2 = new MenuAction(2, "Check it one more", "Test"); MenuActionService menuActionService = new MenuActionService(); menuActionService.AddItem(menuAction1); menuActionService.AddItem(menuAction2); //Act List <MenuAction> result = menuActionService.GetMenuActionsByMenuName("Test"); //Assert result.Should().NotBeNullOrEmpty(); result.Should().HaveCount(2); result.Should().StartWith(menuAction1); //Clear menuActionService.RemoveItem(menuAction1); menuActionService.RemoveItem(menuAction2); }
private void MainMenu() { bool isProgramActive = true; while (isProgramActive) { System.Console.WriteLine("Planer budżetu domowego!"); System.Console.WriteLine("Wpisz liczbę odpowiadającą temu, co chcesz zrobić."); System.Console.WriteLine(); var mainMenu = actionService.GetMenuActionsByMenuName("Main"); for (int i = 0; i < mainMenu.Count; i++) { Console.WriteLine($"{mainMenu[i].Id}. {mainMenu[i].Name}"); } var operation = operationService.ReadNumberOperation(); switch (operation) { case 1: CreateMenuView(MenuOption.HomeBudgetMenu); break; case 2: CreateMenuView(MenuOption.ExpenseMenu); break; case 3: CreateMenuView(MenuOption.FundsMenu); break; default: isProgramActive = false; break; } } }
public static CharacterManager FightMenu(MenuActionService actionService, CharacterManager characterManager, ItemManager itemManager) { bool isMonsterLive = true; bool isHeroLive = true; bool isEscaped = false; IEnemyService enemyService = new EnemyService(); enemyService.GenerateNewEnemy(characterManager.GetHeroLevel()); int[] hiddenHeroStats = characterManager.GetHiddenStats(); int[] hiddenEnemyStats = enemyService.GetHiddenStats(); do { Console.Clear(); Console.WriteLine("Your hero:"); characterManager.ShowHeroInfoInFight(); Console.WriteLine(); enemyService.ShowMonsterInfo(); List <MenuAction> dungeonMenu = actionService.GetMenuActionsByMenuName("Fight"); int selectedOption; Console.WriteLine(); for (int i = 0; i < dungeonMenu.Count; i++) { Console.WriteLine($"{dungeonMenu[i].Id}. {dungeonMenu[i].Name}"); } var readedKey = Console.ReadKey(); Int32.TryParse(readedKey.KeyChar.ToString(), out selectedOption); switch (selectedOption) { case 1: if (hiddenHeroStats[1] >= hiddenEnemyStats[1]) { isMonsterLive = enemyService.DealDamage(hiddenHeroStats[0]); Console.Read(); if (isMonsterLive) { isHeroLive = characterManager.GetDamage(hiddenEnemyStats[0]); } } else { isHeroLive = characterManager.GetDamage(hiddenEnemyStats[0]); Console.Read(); if (isHeroLive) { isMonsterLive = enemyService.DealDamage(hiddenHeroStats[0]); } } break; case 2: int selectedItem; do { List <Item> heroItems = characterManager.GetItems(); Console.Clear(); int counter = 1; Console.WriteLine("Your inventory:"); foreach (var item in heroItems) { Console.WriteLine($"{counter}. {item.Name}"); counter++; } Console.WriteLine("0. Exit"); int.TryParse(Console.ReadKey().KeyChar.ToString(), out selectedItem); Console.Clear(); if (selectedItem != 0 && selectedItem - 1 < heroItems.Count) { if (heroItems[selectedItem - 1].IsUsable) { characterManager.UseItem(selectedItem - 1); } else { Console.WriteLine("This item is not usable"); } } else { Console.WriteLine("You have chosen wrong number"); } Console.Read(); Console.Clear(); } while (selectedItem != 0); break; case 3: isEscaped = TryToEscape(hiddenHeroStats[1], hiddenEnemyStats[1]); if (!isEscaped) { Console.Clear(); Console.WriteLine("Ups your enemy was too quick!"); Console.WriteLine("Click enter to continue..."); Console.Read(); isHeroLive = characterManager.GetDamage(hiddenEnemyStats[0]); } break; default: Console.WriteLine("Wrong option number"); break; } } while (isMonsterLive && isHeroLive && !isEscaped); if (!isHeroLive) { return(null); } if (!isEscaped) { Random money = new Random(); Random experience = new Random(); Item item = itemManager.GetRandomItem(characterManager.GetHeroLevel(), characterManager.GetHeroClass()); int heroLevel = characterManager.GetHeroLevel(); int gainedMoney = money.Next(25 * heroLevel, 150 * heroLevel); int gainedExp = experience.Next(10 * heroLevel, 200 * heroLevel); Console.Clear(); if (!characterManager.CheckIsInventoryFull()) { int numberOfItems = characterManager.AddItemToInventory(item); Console.WriteLine($"You got item: {item.Name}"); Console.WriteLine($"You have {numberOfItems} items in your inventory"); } Messages.AfterFight(gainedExp, gainedMoney); characterManager.UpdateCharacterAfterFight(gainedMoney, gainedExp); } return(characterManager); }
public void GameMenu() { while (true) { Console.Clear(); Console.WriteLine($"What do you want to do {_characterManager.GetCharacterName()}"); foreach (var action in _actionService.GetMenuActionsByMenuName("Game Menu")) { Console.WriteLine($"{action.Id}. {action.Name}"); } int chosenOption; int.TryParse(Console.ReadKey().KeyChar.ToString(), out chosenOption); Console.Clear(); switch (chosenOption) { case 1: DungeonManager dungeonService = new DungeonManager(_characterManager, _itemManager); int selectedOption = 0; bool isDungeonFinished = false; do { Console.Clear(); selectedOption = dungeonService.DungeonMenu(_actionService); switch (selectedOption) { case 1: if (dungeonService.CheckCount()) { dungeonService.NextFight(_actionService); } else { isDungeonFinished = true; _characterManager = dungeonService.ExitMenu(); } break; case 2: Console.Clear(); int cost = 250 * _characterManager.GetHeroLevel(); Console.WriteLine($"Do you want to heal your hero for {cost} gold? (y/n)"); var confirmHeal = Console.ReadLine(); if (confirmHeal == "y" || confirmHeal == "Y") { if (_characterManager.Heal(cost)) { Console.WriteLine("Your hero was fully healed!"); } else { Console.WriteLine("Sorry you don't have enough gold"); } } break; case 3: isDungeonFinished = true; _characterManager = dungeonService.ExitMenu(); break; } } while (!isDungeonFinished); _characterManager.SaveCharacter(); break; case 2: ShopManager shop = new ShopManager(_itemManager, _characterManager); shop.ShowMenu(); break; case 3: Console.Clear(); int i = _characterManager.CharacterInfo(); break; case 4: Messages.SaveResult(_characterManager.SaveCharacter()); break; case 5: Messages.Exit(); break; default: Messages.WrongOption(); Console.Clear(); break; } } }
static void Main(string[] args) { MenuActionService menuActionService = new MenuActionService(); HeroService heroService = new HeroService(); HeroManager heroManager = new HeroManager(menuActionService, heroService); EnemyService enemyService = new EnemyService(); StoryManager storyManager; int tryHard = 0; bool choseLvlOne = false; bool choseLvlTwo = false; bool choseLvlThree = false; int lastDiffLvl = 0; List <Hero> heroes = null; Console.WriteLine("Welcome to RPG Game app!"); while (true) { int exit = 0; Console.WriteLine("Please let me know what you want to do:"); var mainMenu = menuActionService.GetMenuActionsByMenuName("Main"); for (int i = 0; i < mainMenu.Count; i++) { Console.WriteLine($"{mainMenu[i].Id}. {mainMenu[i].Name}"); } var operation = Console.ReadKey(); switch (operation.KeyChar) { case '1': var newId = heroManager.AddNewHero(); break; case '2': heroManager.RemoveHero(); break; case '3': heroManager.HeroDetails(); break; case '4': var toShow = heroManager.ShowHeroes(); Console.WriteLine(toShow.ToStringTable(new[] { "Id", "Name", "Health", "Max Health", "Attack", "Heal Level", "Experience", "Level", "Required Experience", "Profession", "Typ Id" }, a => a.Id, a => a.Name, a => a.Health, a => a.MaxHealth, a => a.Attack, a => a.HealLvl, a => a.Exp, a => a.Level, a => a.RequiredExp, a => a.Profession, a => a.TypeId)); break; case '5': heroes = heroManager.GetAllHeroes(); if (heroes.Count > 0) { Console.WriteLine(); Console.WriteLine(heroes.ToStringTable(new[] { "Id", "Name", "Health", "Max Health", "Attack", "Heal Level", "Experience", "Level", "Required Experience", "Profession", "Typ Id" }, a => a.Id, a => a.Name, a => a.Health, a => a.MaxHealth, a => a.Attack, a => a.HealLvl, a => a.Exp, a => a.Level, a => a.RequiredExp, a => a.Profession, a => a.TypeId)); int chosenHero = -1; Hero hero = null; while (hero == null) { chosenHero = heroManager.SelectCharacter(); if (chosenHero == -1) { break; } hero = heroManager.GetHeroById(chosenHero); } if (chosenHero != -1) { Console.WriteLine($"You chose Hero {hero.Name}, level:{hero.Level}, profession:{hero.Profession}"); storyManager = new StoryManager(menuActionService, hero, enemyService); storyManager.SetLastDiffLvl(lastDiffLvl); storyManager.Start(); if (storyManager.DiffLvl == lastDiffLvl) { tryHard++; enemyService.UpgradeEnemiesByDiffLvl(tryHard, storyManager.DiffLvl); } else { tryHard = 0; } lastDiffLvl = storyManager.DiffLvl; hero.Reset(); switch (storyManager.DiffLvl) { case 1: choseLvlOne = true; break; case 2: choseLvlTwo = true; break; case 3: choseLvlThree = true; break; } if (choseLvlOne && choseLvlTwo && choseLvlThree) { enemyService.UpgradeEnemies(1); choseLvlOne = false; choseLvlTwo = false; choseLvlThree = false; } } } else { Console.WriteLine("\nThere is no heroes to choose"); } break; case '6': exit = 1; if (heroes != null) { bool IsFileCreated = CreateXmlFileWithAllHeroes(heroes); if (IsFileCreated) { Console.WriteLine("\nSaved all Heroes in file listOfAllHeroes.xml"); } } Console.WriteLine("Press Enter to continue"); Console.ReadLine(); break; default: Console.WriteLine("Action you entered does not exist"); break; } if (exit == 1) { break; } } }
static void Main(string[] args) { FileManager fileManager = new FileManager(); InformationProvider informationProvider = new InformationProvider(); MenuActionService actionService = new MenuActionService(); IService <Exercise> exerciseService = new ExerciseService(); IService <Routine> routineService = new RoutineService(); ExerciseManager exerciseManager = new ExerciseManager(actionService, exerciseService, informationProvider, fileManager); RoutineManager routineManager = new RoutineManager(routineService, informationProvider, fileManager); Console.WriteLine("Welcome to Gymate app!"); exerciseManager.GetAddedExercicesFromFile(); routineManager.GetAddedRoutineFromFile(); while (true) { informationProvider.ShowSingleMessage("Please let me know what you want to do:"); var mainMenu = actionService.GetMenuActionsByMenuName("Main"); foreach (var menuAction in mainMenu) { informationProvider.ShowSingleMessage($"{menuAction.Id}. {menuAction.Name}"); } var operation = informationProvider.GetInputString(); Console.WriteLine("\n"); switch (operation) { case "1": exerciseManager.AddNewExercise(); break; case "2": exerciseManager.RemoveExercise(); break; case "3": exerciseManager.ShowAllExercises(); break; case "4": exerciseManager.ViewExerciseDetails(); break; case "5": exerciseManager.ViewExercisesByTypeId(); break; case "6": var dayOfWeekId = routineManager.GetRoutineId(); exerciseManager.ShowAllExercises(); var exerciseToAdd = exerciseManager.GetExerciseById(); routineManager.AddSelectedExerciseToRoutineDay(dayOfWeekId, exerciseToAdd); break; case "7": routineManager.ShowWholeRoutine(); break; case "8": exerciseManager.UpdateVolumeInExercise(); break; case "9": exerciseManager.ExportToXml(); break; case "10": routineManager.ExportToXml(); break; default: Console.WriteLine("Action you entered does not exist"); break; } Console.WriteLine("\n"); } }
public void MenuView() { bool isUserInStart = true; while (isUserInStart) { Console.WriteLine("Welcome in the GAME Adventurer!"); foreach (var action in _actionService.GetMenuActionsByMenuName("Start")) { Console.WriteLine($"{action.Id}. {action.Name}"); } int chosenOption; int.TryParse(Console.ReadKey().KeyChar.ToString(), out chosenOption); Console.Clear(); switch (chosenOption) { case 1: var selectedClass = _characterManager.CreateCharacterView(); Console.WriteLine(); Console.WriteLine($"Select name for your {selectedClass}"); var name = Console.ReadLine(); if (_characterManager.CreateCharacter(selectedClass, name)) { isUserInStart = false; } else { do { Console.Clear(); Console.WriteLine("Oops something went wrong :( ."); Console.WriteLine("Click enter to continue"); } while (Console.ReadKey().Key != ConsoleKey.Enter); Console.Clear(); } break; case 2: isUserInStart = Messages.LoadResult(_characterManager.LoadCharacter()); break; case 3: if (File.Exists(SaveManager.saveFile)) { File.Delete(SaveManager.saveFile); } else { do { Console.Clear(); Console.WriteLine("You don't have any saves!"); Console.WriteLine("Click enter to continue"); } while (Console.ReadKey().Key != ConsoleKey.Enter); Console.Clear(); } break; case 4: Messages.Exit(); break; default: Messages.WrongOption(); break; } } Console.Clear(); Game gameMenu = new Game(_characterManager, _actionService); gameMenu.GameMenu(); }
public static void Main(string[] args) { MenuActionService actionService = new MenuActionService(); UserService userService = new UserService(); UserManager userManager = new UserManager(userService); ListService listService = new ListService(userService); listService.ReadDataFromJsonFile(); while (true) { Console.WriteLine("USERS DIRECTORY"); Console.WriteLine("Choose option:"); var mainMenu = actionService.GetMenuActionsByMenuName("MainMenu"); for (int i = 0; i < mainMenu.Count; i++) { Console.WriteLine(mainMenu[i].Id + " " + mainMenu[i].Name); } var opertion = Console.ReadKey(); Console.Clear(); switch (opertion.KeyChar) { case '1': var newUserId = userManager.AddUserManager(); listService.SaveDataToJsonFile(); break; case '2': var removeUserId = userManager.RemoveUserManager(); listService.SaveDataToJsonFile(); break; case '3': var detailsUserId = userManager.GetUserDetailsManager(); break; case '4': userManager.GetUserByCityManager(); break; case '5': userManager.GetAllUsersManager(); break; case '6': userManager.UpdateUserManager(); listService.SaveDataToJsonFile(); break; case '7': actionService.ExitProgram(); break; default: Console.WriteLine("Wrong option"); Console.WriteLine("\nPress any key to back to menu..."); Console.ReadKey(); Console.Clear(); break; } } }
static void Main(string[] args) { //TODO //Logowanie Lekarza ////1. Logowanie ////2. Rejestracja //Menu: ////1. Sprawdz listę pacjentów w bazie ////2. Dodaj nowego pacjenta do listy pacjentów ////3. Usuń pacjenta ////4. Przypisz chorobę do pacjenta ////5. Sprawdz wczesniejsze choroby danego pacjenta (PESEL) ////6. Wygeneruj receptę (.csv) dla pacjenta (wykorzystując gotowy szablon) ////7. Wylogowanie //////2a. Id(numer pacjenta), Imie, Nazwisko, PESEL, Numer telefonu, Adres Email //////3a. Usuwanie poprzez podanie id lub numeru PESEL //////4a. Wybór kategorii: Zakaźna, Nowotwór, Przewlekła, Cywilizacyjna, Psychiczne, Genetyczne itd... //////4b. Wybór stopnia zaawansowania choroby (1-5) - różny kolor czcionki przy wypisywaniu w konsoli //////4c. Opis objawów //////4d. Zalecenia //////5a. //////6a. Recepta: id lekarza, Zalecenia, Dawkowanie leków string path = Directory.GetCurrentDirectory(); MenuActionService menuActionService = new MenuActionService(); var loginMenu = menuActionService.GetMenuActionsByMenuName("Login"); UserService userService = new UserService(); UserManager userManager = new UserManager(userService); User user = new User(); bool isAnOption = true; do { Console.WriteLine("Please choose what you want to do: "); foreach (var element in loginMenu) { Console.WriteLine($"{ element.Id }. {element.Name}"); } do { var option = Console.ReadKey(); switch (option.KeyChar) { case '1': Console.Clear(); Console.WriteLine($"===Log in==="); user = userManager.GetLoginData(user); ConsoleActions.ShowWaitingDots(); break; case '2': Console.Clear(); Console.WriteLine($"===Register==="); user = userManager.GetRegisterData(user); Console.WriteLine($"You have successfully registered! Your ID number is: {user.Id}"); ConsoleActions.ShowWaitingDots(); break; default: ConsoleActions.ClearChosenNumberFromLine(); Console.WriteLine($"Operation number {option.KeyChar} does not exist please try again"); isAnOption = false; break; } }while (!isAnOption); }while (!user.IsLoggedIn); //User can choose what he want to do loginMenu = menuActionService.GetMenuActionsByMenuName("mainMenu"); IllnessActionService illnessActionService = new IllnessActionService(); IllnessActionManager illnessActionManager = new IllnessActionManager(illnessActionService); PatientService patientService = new PatientService(); PatientManager patientManager = new PatientManager(patientService); bool quit = true; do { Console.WriteLine("Please choose what you want to do: "); foreach (var element in loginMenu) { Console.WriteLine($"{ element.Id }. {element.Name}"); } var option = Console.ReadKey(); switch (option.KeyChar) { case '1': Console.Clear(); List <Patient> patients = new List <Patient>(); patients = patientService.GetAll(); foreach (var patient in patients) { Console.WriteLine($"{patient.Id} | " + $"{patient.FirstName} {patient.LastName} | " + $"PESEL: {patient.PESEL} | " + $"Tel: {patient.PhoneNumber} | " + $"E-mail: {patient.EmailAdress}"); } quit = false; break; case '2': Console.Clear(); patientManager.GetNewPatientData(user); quit = false; break; case '3': Console.Clear(); Console.WriteLine("Do you want to remove by PESEL number or ID number: \n1. PESEL\n2. ID"); option = Console.ReadKey(); switch (option.KeyChar) { case '1': string pesel; Console.Write("Please write patient's PESEL number: "); pesel = Console.ReadLine(); patientManager.Remove(pesel); break; case '2': int id; Console.Write("Please write patient's ID number: "); Int32.TryParse(Console.ReadLine(), out id); patientManager.Remove(id); break; default: Console.WriteLine($"Operation number { option.KeyChar} does not exist."); break; } quit = false; break; case '4': Console.Clear(); illnessActionManager.GetPatientAndIllnessData(user, patientService); ConsoleActions.ShowWaitingDots(); quit = false; break; case '5': Console.Clear(); Console.WriteLine("Do you want to search by PESEL number or ID number: \n1. PESEL\n2. ID\n"); option = Console.ReadKey(); XmlRootAttribute root = new XmlRootAttribute(); root = new XmlRootAttribute(); root.ElementName = "Illnesses"; root.IsNullable = true; XmlSerializer xmlSerializer = new XmlSerializer(typeof(List <IllnessAction>), root); switch (option.KeyChar) { case '1': ConsoleActions.ClearChosenNumberFromLine(); string pesel; Console.Write("Please write patient's PESEL number: "); pesel = Console.ReadLine(); var illnesses = illnessActionManager.GetInfoToSerializeCSV(pesel); xmlSerializer.Serialize(new StreamWriter(path + $@"\illnesses_xml\{patientManager.GetByPesel(pesel).PESEL}.xml"), illnesses); break; case '2': ConsoleActions.ClearChosenNumberFromLine(); int id; Console.Write("Please write patient's ID number: "); Int32.TryParse(Console.ReadLine(), out id); illnesses = illnessActionManager.GetInfoToSerializeCSV(id); xmlSerializer.Serialize(new StreamWriter(path + $@"\illnesses_xml\{patientManager.GetById(id).PESEL}.xml"), illnesses); break; default: ConsoleActions.ClearChosenNumberFromLine(); Console.WriteLine($"Operation number { option.KeyChar} does not exist."); break; } quit = false; break; case '6': ConsoleActions.ClearChosenNumberFromLine(); Console.Write("Please write PESEL number of patient to read his/her prescription: "); string peselFileName; peselFileName = Console.ReadLine(); root = new XmlRootAttribute(); root.ElementName = "Illnesses"; root.IsNullable = true; xmlSerializer = new XmlSerializer(typeof(List <IllnessAction>), root); string xml = File.ReadAllText(path + $@"\illnesses_xml\{peselFileName}.xml"); StringReader stringReader = new StringReader(xml); var illnessItems = (List <IllnessAction>)xmlSerializer.Deserialize(stringReader); foreach (var item in illnessItems) { Console.Write(item.Id + " | " + item.NameOfIllness + " | " + item.IllnessLevel + " | " + item.DateOfControlVisit + " | " + item.Category); Console.WriteLine("============================================="); } break; case 'q': quit = true; break; default: Console.Clear(); Console.WriteLine($"Operation number {option.KeyChar} does not exist please try again"); quit = false; break; } }while (!quit); }