2025-05-26 09:40:01 +00:00
|
|
|
#include <iostream>
|
2025-05-28 08:54:22 +00:00
|
|
|
#include <cctype>
|
2025-05-28 10:33:11 +00:00
|
|
|
#include "Errorseal.h"
|
2025-05-28 08:54:22 +00:00
|
|
|
#include "AtmAdmin.h"
|
|
|
|
|
2025-05-28 10:33:11 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2025-05-28 08:54:22 +00:00
|
|
|
bool handleUserInformation(char choice, std::string& information) {
|
2025-05-28 10:33:11 +00:00
|
|
|
std::string tempInformation{};
|
|
|
|
|
2025-05-28 08:54:22 +00:00
|
|
|
switch (choice) {
|
|
|
|
case '1':
|
2025-05-28 09:14:16 +00:00
|
|
|
// Implement a proper function for entering a new pin.
|
2025-05-28 10:33:11 +00:00
|
|
|
// The function should have a somewhat complex algorithm that forces the pin to be secure and unique.
|
2025-05-28 09:14:16 +00:00
|
|
|
// It should also enforce 4 numbers.
|
|
|
|
|
2025-05-28 10:33:11 +00:00
|
|
|
// The code below is a placeholder.
|
|
|
|
tempInformation = changeAccountPin();
|
|
|
|
if (tempInformation != "invalid") {
|
|
|
|
information = tempInformation;
|
|
|
|
return true;
|
|
|
|
}
|
2025-05-28 08:54:22 +00:00
|
|
|
break;
|
|
|
|
case '2':
|
2025-05-28 09:14:16 +00:00
|
|
|
// Implement a function for entering a new username.
|
|
|
|
// The function should check if the name isn't already taken. If it is, return to start.
|
|
|
|
// It will also use an algorithm to check if it's a valid username
|
|
|
|
// This includes no spaces and no starting numbers.
|
|
|
|
// Ensure that the name is also converted to fully lowercase.
|
|
|
|
|
2025-05-28 10:33:11 +00:00
|
|
|
// The code below is a placeholder
|
2025-05-28 09:14:16 +00:00
|
|
|
std::cout << "Enter your new username: ";
|
2025-05-28 08:54:22 +00:00
|
|
|
std::cin >> information;
|
|
|
|
break;
|
|
|
|
case '3':
|
2025-05-28 09:14:16 +00:00
|
|
|
// Simply a way to cheat, very straight-forward.
|
|
|
|
|
2025-05-28 10:33:11 +00:00
|
|
|
// The code below is a placeholder
|
2025-05-28 09:14:16 +00:00
|
|
|
std::cout << "Enter the amount you wish to have: ";
|
2025-05-28 08:54:22 +00:00
|
|
|
std::cin >> information;
|
|
|
|
break;
|
|
|
|
case 'q':
|
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
std::cout << "Invalid choice.\n";
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2025-05-26 09:40:01 +00:00
|
|
|
|
|
|
|
int main() {
|
2025-05-28 08:54:22 +00:00
|
|
|
bool continueLoop{true};
|
|
|
|
|
|
|
|
while (continueLoop) {
|
|
|
|
// startup() presents the user with the choices below, which are then stored and used by other functions.
|
|
|
|
// The other functions should handle invalid choices.
|
|
|
|
// ((1. Change pin || 2. Change money || 3. Change account name || Q. Exit the program))
|
|
|
|
char userChoice{AtmAdmin::startup()};
|
|
|
|
|
|
|
|
// userInformation will later store information for the XML entry to save.
|
|
|
|
std::string userInformation{};
|
|
|
|
|
|
|
|
// Always returns true unless 'Q' is entered
|
|
|
|
continueLoop = handleUserInformation(static_cast<char>(std::tolower(userChoice)), userInformation);
|
|
|
|
|
|
|
|
std::cout << userInformation << '\n'; // DEBUG
|
|
|
|
}
|
2025-05-26 09:40:01 +00:00
|
|
|
}
|