From dba3851acae089cac747303cfb8268372c394d6e Mon Sep 17 00:00:00 2001 From: theskywinds Date: Wed, 18 Jun 2025 09:22:48 +0200 Subject: [PATCH] Fully implemented name & PIN change --- src/AtmAdmin.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/AtmAdmin.cpp b/src/AtmAdmin.cpp index c8f5693..abd7e61 100644 --- a/src/AtmAdmin.cpp +++ b/src/AtmAdmin.cpp @@ -34,7 +34,7 @@ namespace AtmAdmin { // It also saves and applies the information if the user accepts it. void confirmUserInformation (XMLStorage& mainStorage, const std::string& tempInformation, const Choice choice) { char userCheck; - bool loopDone = true; + bool loopDone{true}; do { if (choice == PIN) @@ -201,23 +201,16 @@ namespace AtmAdmin { // CONSTRAINTS FOR FIRST NAME if (firstName.empty()) { errorReport("First name cannot be empty."); + return ("invalid"); } // Checks for letters that aren't alphabetical. if (std::ranges::any_of(firstName.cbegin(), firstName.cend(), [] (unsigned char input) { - return !std::isalpha(input) and !std::isspace(input); + return !std::isalpha(input); })) { - errorReport("Name cannot contain non-alphabetic letters."); + errorReport("Name cannot contain non-alphabetic letters or spaces."); return ("invalid"); } - - // Checks for any spaces in the first name. - if (std::ranges::any_of(firstName.cbegin(), firstName.cend(), [] (char input) { - return input == ' '; - })) { - errorReport("First & last name cannot contain spaces."); - return "invalid"; - } // ENDING CONSTRAINTS FOR FIRST NAME std::cout << "Enter your last name(s): ";