-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
93 lines (77 loc) · 3.59 KB
/
Program.cs
File metadata and controls
93 lines (77 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using System.Globalization;
class Program
{
// Application global state - accessible from all parts of the program
public static Dictionary<ExpenseCategory, decimal> categoryBudgets = [];
public static List<FinancialGoal> goals = [];
public static List<Expense> expenses = [];
/// <summary>
/// Main entry point of the Finance Flow Planner application
/// Responsible for initialization, main loop, and cleanup
/// </summary>
static void Main()
{
// Set German culture for consistent currency formatting (€ symbol, decimal separators)
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("de-DE");
CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("de-DE");
Console.Clear(); // Start with clean console
Console.WriteLine(); // Empty line for better visual spacing
// Show motivational quote to encourage users
MotivationService.ShowMotivation();
// Load persisted data from JSON files
var (loadedGoals, loadedExpenses) = JsonDataService.LoadData();
goals = loadedGoals;
expenses = loadedExpenses;
// Load category budgets (separate from main data)
categoryBudgets = JsonDataService.LoadBudgets();
// Main application loop - runs until user chooses to exit
while (true)
{
// Display main menu with all available options
MenuManager.ShowMainMenu();
string? choiceInput = Console.ReadLine();
// Validate and parse user input
if (int.TryParse(choiceInput, out int choice))
{
// Route user choice to appropriate functionality
switch (choice)
{
case 0: // Exit application
JsonDataService.SaveFinanceData(goals, expenses); // Persist before exit
Console.WriteLine("Closing program...");
return; // Exit Main() method, ending the program
case 1: // Add new financial goal
GoalManager.AddFinancialGoal();
break;
case 2: // View existing goals
MenuManager.ShowGoals();
break;
case 3: // Add new expense
ExpenseManager.AddExpense();
break;
case 4: // View expense history
MenuManager.ShowExpenses();
break;
case 5: // Manage category budgets
BudgetManager.ManageBudgets();
break;
case 6: // Show spending analytics and insights
MenuManager.ShowAnalytics();
break;
case 7: // Export data in PDF
PdfExportService.PdfExport();
break;
default: // Invalid menu option
Console.Clear();
ColorPrinter.PrintColor("⚠️ Wrong menu index!", ConsoleColor.Yellow);
break;
}
}
else // Non-numeric input
{
Console.Clear();
ColorPrinter.PrintColor("❌ Error: Wrong input format!", ConsoleColor.Red);
}
}
}
}