From 4f1a32abf159e0a8ac5a3a77788c6198522328de Mon Sep 17 00:00:00 2001 From: Rinats Andrejevs Date: Tue, 30 Apr 2024 10:02:11 +0000 Subject: [PATCH] Update main.cpp --- main.cpp | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/main.cpp b/main.cpp index 703348f..093abac 100644 --- a/main.cpp +++ b/main.cpp @@ -4,14 +4,14 @@ #include #include #include -using namespace std; +using namespace std; //Bibliotēku savienošana -class User { +class User { //User klasu izveidošana datu saglabašanai public: string name, password; }; -class FinancialRecord { +class FinancialRecord { //FinancialRecord klasu izveidošana datu saglabašanai public: string id, date, description; double profit, loss; @@ -21,7 +21,7 @@ public: }; -vector split(string str, char delimiter) { +vector split(string str, char delimiter) { //Funkcija lai sadalītu informāciju txt filā vector result; stringstream ss(str); string item; @@ -31,7 +31,7 @@ vector split(string str, char delimiter) { return result; } -void register_user(vector& users) { +void register_user(vector& users) { //Funkcija lai registretu lietotaju cout << "\nRegistering a new user\n"; string name, password; cout << "Enter new user name: "; @@ -45,7 +45,7 @@ void register_user(vector& users) { cout << "\nNew user has been registered successfully."; } -bool login_user(const vector& users, string& username, string& password) { +bool login_user(const vector& users, string& username, string& password) { //Funkcija lai iejiet izveidota lietotajā cout << "\nLogging in...\n"; cout << "Enter username: "; cin >> username; @@ -61,7 +61,7 @@ bool login_user(const vector& users, string& username, string& password) { return false; } -void display_additional_menu() { +void display_additional_menu() { //Izvelne lietotajam cout << "\nAdditional Menu:\n"; cout << "1. Add Record\n"; cout << "2. Edit User\n"; @@ -78,7 +78,7 @@ void display_additional_menu() { cout << "0. Exit\n"; } -void add_record(vector& records) { +void add_record(vector& records) { //Funkcija lai pievienotu ierakstu cout << "\nAdding a new financial record...\n"; string id, date, description; double profit, loss; @@ -97,7 +97,7 @@ void add_record(vector& records) { records.push_back(FinancialRecord(to_string(next_id), date, description, profit, loss)); } -void edit_user(vector& users) { +void edit_user(vector& users) { //Funkcija lai samainitu lietotaja datus cout << "\nEditing user details...\n"; string username, new_name, new_password; cout << "Enter username to edit: "; @@ -117,7 +117,7 @@ void edit_user(vector& users) { cout << "User not found.\n"; } -void delete_user(vector& users) { +void delete_user(vector& users) { //Funkcija lai izdsestu lietotaju cout << "\nDeleting a user...\n"; string username; cout << "Enter username to delete: "; @@ -132,7 +132,7 @@ void delete_user(vector& users) { cout << "User not found.\n"; } -void edit_record(vector& records) { +void edit_record(vector& records) { //Funkcija lai samainitu datus par izrakstu cout << "\nEditing a financial record...\n"; string record_id; cout << "Enter the ID of the record you want to edit: "; @@ -156,7 +156,7 @@ void edit_record(vector& records) { cout << "Record not found.\n"; } -void delete_record(vector& records) { +void delete_record(vector& records) { //Funkcija lai izdsestu izrakstu cout << "\nDeleting a financial record...\n"; string record_id; cout << "Enter the ID of the record you want to delete: "; @@ -172,7 +172,7 @@ void delete_record(vector& records) { cout << "Record not found.\n"; } -void output_analytics(const vector& records) { +void output_analytics(const vector& records) { //Funkcija lai izvadit analitiskus datus cout << "\nGenerating analytics data...\n"; double total_profit = 0, total_loss = 0; for (const FinancialRecord& record : records) { @@ -184,7 +184,7 @@ void output_analytics(const vector& records) { cout << "Net Profit: $" << (total_profit - total_loss) << endl; } -void save_records_to_file(const vector& records) { +void save_records_to_file(const vector& records) { //Funkcija lai saglabatu izrakstus txt filā cout << "\nSaving records to a file...\n"; ofstream outfile("financial_records.txt"); if (outfile.is_open()) { @@ -209,7 +209,7 @@ void draw_graph() { cout << "\nDrawing graphs..."; } -void total_value(const vector& records) { +void total_value(const vector& records) { //Funkcija lai paradītu pilna darījumu summa cout << "\nCalculating total value...\n"; double total_profit = 0; for (const FinancialRecord& record : records) { @@ -218,7 +218,7 @@ void total_value(const vector& records) { cout << "Total profit: $" << total_profit << endl; } -void output_loss(const vector& records) { +void output_loss(const vector& records) { //Funkcija lai paradītu pilna darījumu summa cout << "\nCalculating and displaying loss...\n"; double total_loss = 0; for (const FinancialRecord& record : records) { @@ -227,7 +227,7 @@ void output_loss(const vector& records) { cout << "Total loss: $" << total_loss << endl; } -void output_profit(const vector& records) { +void output_profit(const vector& records) { //Funkcija lai paradītu pilno peļņu cout << "\nCalculating and displaying profit...\n"; double total_value = 0; for (const FinancialRecord& record : records) { @@ -238,7 +238,7 @@ void output_profit(const vector& records) { int main() { - vector records; + vector records; //vektors kur saglabas izraksti (records) vector users; int choice; @@ -248,10 +248,10 @@ int main() { cin >> choice; switch (choice) { case 1: - register_user(users); + register_user(users); //reģistrācija jauno lietotāju break; case 2: - if (login_user(users, username, password)) { + if (login_user(users, username, password)) { //Iejiet jau izveidotā lietotajā int additional_choice; do { display_additional_menu(); @@ -304,7 +304,7 @@ int main() { } break; case 3: - cout << "\nExiting program...\n"; + cout << "\nExiting program...\n"; //exit programma break; default: cout << "\nInvalid choice. Please try again.\n";