Begun work on changeAccountName()
This commit is contained in:
parent
42d4704b0f
commit
36b46c6899
|
@ -6,7 +6,6 @@
|
||||||
#include <oneapi/tbb/detail/_task.h>
|
#include <oneapi/tbb/detail/_task.h>
|
||||||
|
|
||||||
namespace AtmAdmin {
|
namespace AtmAdmin {
|
||||||
|
|
||||||
char startup() {
|
char startup() {
|
||||||
char choice{};
|
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 << "1. Change PIN\n" << "2. Change account name\n" << "3. Change money\n" << "Q. Exit the program\n\n";
|
||||||
|
@ -23,11 +22,6 @@ namespace AtmAdmin {
|
||||||
|
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
case '1':
|
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.
|
|
||||||
// It should also enforce 4 numbers.
|
|
||||||
|
|
||||||
// The code below is a placeholder.
|
|
||||||
tempInformation = changeAccountPin();
|
tempInformation = changeAccountPin();
|
||||||
if (tempInformation != "invalid") {
|
if (tempInformation != "invalid") {
|
||||||
information = tempInformation;
|
information = tempInformation;
|
||||||
|
@ -60,17 +54,16 @@ namespace AtmAdmin {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allows for the quick and clean creation of error reports.
|
||||||
|
void errorReport (std::string_view error) {
|
||||||
|
std::cout << error << '\n';
|
||||||
|
std::cout << "Press enter to continue...";
|
||||||
|
std::cin.get();
|
||||||
|
};
|
||||||
|
|
||||||
std::string changeAccountPin() {
|
std::string changeAccountPin() {
|
||||||
std::string newPin{};
|
std::string newPin{};
|
||||||
|
|
||||||
// Allows for the quick and clean creation of error reports.
|
|
||||||
auto errorReport = [] (std::string_view error) {
|
|
||||||
std::cout << error << '\n';
|
|
||||||
std::cout << "Press enter to continue...";
|
|
||||||
std::cin.get();
|
|
||||||
return "invalid";
|
|
||||||
};
|
|
||||||
|
|
||||||
std::cout << "Enter new pin: ";
|
std::cout << "Enter new pin: ";
|
||||||
std::cin >> newPin;
|
std::cin >> newPin;
|
||||||
Error::ignoreLine();
|
Error::ignoreLine();
|
||||||
|
@ -111,4 +104,18 @@ namespace AtmAdmin {
|
||||||
|
|
||||||
return newPin;
|
return newPin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string changeAccountName() {
|
||||||
|
std::string newName{};
|
||||||
|
|
||||||
|
std::cout << "Enter new name: ";
|
||||||
|
std::cin >> newName;
|
||||||
|
Error::ignoreLine();
|
||||||
|
|
||||||
|
if (newName.size() < 2 or newName.size() > 10) {
|
||||||
|
errorReport("Name has to be between 2 and 10 characters.");
|
||||||
|
return "invalid";
|
||||||
|
}
|
||||||
|
return newName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user