Skip to content

Commit

Permalink
refactoring code
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyasbozdemir committed Mar 20, 2024
1 parent 372138e commit 5ac2b49
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
1 change: 0 additions & 1 deletion quiz-console-app/Helpers/QuestionShuffler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public static void ShuffleBookletQuestions(BookletViewModel booklet)
booklet.Questions = booklet.Questions.OrderBy(q => random.Next()).ToList();
}


public static List<BookletQuestion> ShuffleQuestionOptions(List<BookletQuestion> questions)
{

Expand Down
20 changes: 12 additions & 8 deletions quiz-console-app/Models/MenuManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@ public MenuManager()
ErrorMessage = "Geçersiz seçim. Lütfen geçerli bir seçenek girin.";
}

public void AddMenuOption(MenuOption option)
{
menuOptions[option.Id] = option;
}
public void AddMenuOption(MenuOption option) => menuOptions[option.Id] = option;


public void AddMenuOptions(MenuOption[] options)
{
foreach (MenuOption option in options)
{
AddMenuOption(option);
}
}

public void DisplayMenu()
public void ExecuteMenu()
{
DisplayMenu();
HandleSelection();
}


private void DisplayMenu()
{
for (int i = 0; i < menuOptions.Count; i++)
{
Expand All @@ -48,7 +51,7 @@ public void DisplayMenu()
}
}

public void HandleSelection()
private void HandleSelection()
{
bool menuState = true;

Expand All @@ -73,5 +76,6 @@ public void HandleSelection()
ConsoleHelper.WriteColored("Çıkış için enter tuşuna basın.", ConsoleColors.Debug);
Console.ReadLine();
}

}

4 changes: 1 addition & 3 deletions quiz-console-app/Screens/ExportDataScreen.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using quiz_console_app.Constants;
using quiz_console_app.Models;
using quiz_console_app.Services;

namespace quiz_console_app.Screens;

Expand All @@ -10,8 +9,7 @@ public void DisplayMenuOptions()
{
MenuManager menuManager = new MenuManager();
menuManager.AddMenuOptions(MenuOptions.ExportOptions);
menuManager.DisplayMenu();
menuManager.HandleSelection();
menuManager.ExecuteMenu();
}


Expand Down
3 changes: 1 addition & 2 deletions quiz-console-app/Screens/QuizMainMenuScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ public void Show()
{
MenuManager menuManager = new MenuManager();
menuManager.AddMenuOptions(MenuOptions.GeneralOptions);
menuManager.DisplayMenu();
menuManager.HandleSelection();
menuManager.ExecuteMenu();
}
}

0 comments on commit 5ac2b49

Please sign in to comment.