From 4817c36eae5989a898dc13d3fc2d1990e0b83241 Mon Sep 17 00:00:00 2001 From: theskywinds Date: Wed, 28 May 2025 12:33:11 +0200 Subject: [PATCH] Developed a small prototype of changeAccountPin() --- src/main.cpp | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 0cb990b..de0b917 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,18 +1,39 @@ #include #include - +#include "Errorseal.h" #include "AtmAdmin.h" +std::string changeAccountPin() { + std::string newPin{}; + std::cout << "Enter new pin: "; + std::cin >> newPin; + Error::ignoreLine(); + + if (newPin.size() != 4) { + std::cout << "The pin has to be 4 digits long.\n"; + std::cout << "Press enter to continue..."; + std::cin.get(); + return "invalid"; + } + + return newPin; +} + bool handleUserInformation(char choice, std::string& information) { + std::string tempInformation{}; + switch (choice) { case '1': // Implement a proper function for entering a new pin. - // The function should have a somewhat complex algorithm that forces the pin to be secure, and unique. + // The function should have a somewhat complex algorithm that forces the pin to be secure and unique. // It should also enforce 4 numbers. - // Code below is a placeholder. - std::cout << "Enter new pin: "; - std::cin >> information; + // The code below is a placeholder. + tempInformation = changeAccountPin(); + if (tempInformation != "invalid") { + information = tempInformation; + return true; + } break; case '2': // Implement a function for entering a new username. @@ -21,14 +42,14 @@ bool handleUserInformation(char choice, std::string& information) { // This includes no spaces and no starting numbers. // Ensure that the name is also converted to fully lowercase. - // Code below is a placeholder + // The code below is a placeholder std::cout << "Enter your new username: "; std::cin >> information; break; case '3': // Simply a way to cheat, very straight-forward. - // Code below is a placeholder + // The code below is a placeholder std::cout << "Enter the amount you wish to have: "; std::cin >> information; break;