From 022ea7d79df8d63ea13ba65a2cb5588a660712a0 Mon Sep 17 00:00:00 2001 From: theskywinds Date: Wed, 11 Jun 2025 10:52:02 +0200 Subject: [PATCH] Refactored `confirmUserInformation`, updated `startup()` logic, and changed README plans. --- README.md | 2 +- src/AtmAdmin.cpp | 19 +++++-------------- src/main.cpp | 7 +++++++ 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index cd30527..f37ad30 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ An administrative software for use alongside the ATM program at https://www.drag ## Plan This program will allow for the creation of new users, deletion of users, editing of money, changing of pin. -(For the start, simply allow changing the pin & money.) +(For the start, simply allow changing the pin & name.) This program will be terminal-only. ## Current plans diff --git a/src/AtmAdmin.cpp b/src/AtmAdmin.cpp index 14ab24a..a610cfa 100644 --- a/src/AtmAdmin.cpp +++ b/src/AtmAdmin.cpp @@ -7,26 +7,18 @@ #include "Errorseal.h" namespace AtmAdmin { - // Used to make certain functions more concise. + // Used to make certain functions more concise and easier to read. enum Choice { PIN, NAME, MONEY, }; - char startup() { - char choice{}; - std::cout << "1. Change PIN\n" << "2. Change account name\n" << "3. Change money\n" << "Q. Exit the program\n\n"; - std::cout << ">: "; - - std::cin >> choice; - - return choice; - } - - void confirmUserInformation (std::string& information, const std::string& tempInformation, enum Choice choice) { + // Allows the user to double-check their inputted information. + // It also saves and applies the information if the user accepts it. + void confirmUserInformation (std::string& information, const std::string& tempInformation, const Choice choice) { char userCheck; - bool loopDone = true; + [[maybe_unused]] bool loopDone = true; do { if (choice == PIN) @@ -68,7 +60,6 @@ namespace AtmAdmin { // This is handled by the if statement. tempInformation = changeAccountPin(); if (tempInformation != "invalid") { - // Checks with the user if the name is okay, if so, it applies it. confirmUserInformation(information, tempInformation, PIN); return true; } diff --git a/src/main.cpp b/src/main.cpp index f1855e0..9265501 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,8 +2,15 @@ #include #include "AtmAdmin.h" +char startup() { + char choice{}; + std::cout << "1. Change PIN\n" << "2. Change account name\n" << "3. Change money (UNFINISHED)\n" << "Q. Exit the program\n\n"; + std::cout << ">: "; + std::cin >> choice; + return choice; +} int main() { bool continueLoop{true};