-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dc9f258
commit 372138e
Showing
8 changed files
with
144 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using quiz_console_app.Models; | ||
using quiz_console_app.Screens; | ||
|
||
namespace quiz_console_app.Constants; | ||
|
||
public static class MenuOptions | ||
{ | ||
|
||
public static readonly MenuOption[] GeneralOptions = | ||
{ | ||
new MenuOption(1, "Quiz Çözme Modu", () => new QuizModeScreen().StartQuiz()), | ||
new MenuOption(2, "Verileri Oluşturma ve Dışa Aktarma Modu", () => new ExportDataScreen().DisplayMenuOptions()) | ||
}; | ||
|
||
public static readonly MenuOption[] ExportOptions = | ||
{ | ||
new MenuOption(1, "Kitapçık Oluştur ve JSON Olarak Dışa Aktar",() => new ExportDataScreen().CreateAndExportBookletToJson()), | ||
new MenuOption(2, "Kitapçık Oluştur ve XML Olarak Dışa Aktar", () => new ExportDataScreen().CreateAndExportBookletToXml()), | ||
new MenuOption(3, "Kitapçık Oluştur ve CSV Olarak Dışa Aktar", () => new ExportDataScreen().CreateAndExportBookletToCsv()), | ||
new MenuOption(4, "Ana Menüye Dön", () => new ExportDataScreen().ReturnToMainMenu()) | ||
}; | ||
} | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using quiz_console_app.Helpers; | ||
|
||
namespace quiz_console_app.Models; | ||
|
||
public class MenuManager | ||
{ | ||
private readonly Dictionary<int, MenuOption> menuOptions; | ||
public string ErrorMessage { get; set; } | ||
|
||
public MenuManager() | ||
{ | ||
menuOptions = new Dictionary<int, MenuOption>(); | ||
ErrorMessage = "Geçersiz seçim. Lütfen geçerli bir seçenek girin."; | ||
} | ||
|
||
public void AddMenuOption(MenuOption option) | ||
{ | ||
menuOptions[option.Id] = option; | ||
} | ||
|
||
public void AddMenuOptions(MenuOption[] options) | ||
{ | ||
foreach (MenuOption option in options) | ||
{ | ||
AddMenuOption(option); | ||
} | ||
} | ||
|
||
public void DisplayMenu() | ||
{ | ||
for (int i = 0; i < menuOptions.Count; i++) | ||
{ | ||
ErrorMessage += (i != 0) | ||
? (i != menuOptions.Count - 1) | ||
? $", {i + 1}" | ||
: $" veya {i + 1}" | ||
: $"{i + 1}"; | ||
} | ||
|
||
ErrorMessage = $"Geçersiz seçim. Lütfen {ErrorMessage} girin."; | ||
|
||
ConsoleHelper.WriteColoredLine("Seçiminizi yapın\n".ToUpper(), ConsoleColors.Title); | ||
|
||
foreach (var option in menuOptions.Values) | ||
{ | ||
ConsoleHelper.WriteColored($"{option.Id}", ConsoleColors.Info); | ||
Console.WriteLine($" => {option.Name}"); | ||
} | ||
} | ||
|
||
public void HandleSelection() | ||
{ | ||
bool menuState = true; | ||
|
||
while (menuState) | ||
{ | ||
Console.ForegroundColor = ConsoleColors.Prompt; | ||
Console.Write("Seçiminizi yapın: "); | ||
Console.ForegroundColor = ConsoleColors.Default; | ||
string userInput = Console.ReadLine(); | ||
int choice; | ||
|
||
if (int.TryParse(userInput, out choice)) | ||
if (menuOptions.ContainsKey(choice)) | ||
menuOptions[choice].Action(); | ||
else | ||
ConsoleHelper.WriteColoredLine("Geçersiz seçim. Lütfen listedeki bir seçeneği seçin.", ConsoleColors.Error); | ||
else | ||
ConsoleHelper.WriteColoredLine("Geçersiz giriş. Lütfen bir sayı girin.", ConsoleColors.Error); | ||
} | ||
|
||
|
||
ConsoleHelper.WriteColored("Çıkış için enter tuşuna basın.", ConsoleColors.Debug); | ||
Console.ReadLine(); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace quiz_console_app.Models; | ||
|
||
public class MenuOption | ||
{ | ||
public int Id { get; set; } | ||
public string Name { get; set; } | ||
public Action Action { get; set; } | ||
|
||
public MenuOption(int id, string name, Action action) | ||
{ | ||
Id = id; | ||
Name = name; | ||
Action = action; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
using quiz_console_app.Helpers; | ||
using quiz_console_app.Services; | ||
using quiz_console_app.Screens; | ||
|
||
QuizModeHandlerService quizModeHandlerService = new QuizModeHandlerService(); | ||
quizModeHandlerService.ShowMainMenu(); | ||
QuizMainMenuScreen quizModeHandlerService = new QuizMainMenuScreen(); | ||
quizModeHandlerService.Show(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using quiz_console_app.Constants; | ||
using quiz_console_app.Models; | ||
|
||
namespace quiz_console_app.Screens; | ||
|
||
public class QuizMainMenuScreen | ||
{ | ||
public void Show() | ||
{ | ||
MenuManager menuManager = new MenuManager(); | ||
menuManager.AddMenuOptions(MenuOptions.GeneralOptions); | ||
menuManager.DisplayMenu(); | ||
menuManager.HandleSelection(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.