Begun work on changeAccountName()
This commit is contained in:
parent
42d4704b0f
commit
36b46c6899
|
@ -6,7 +6,6 @@
|
|||
#include <oneapi/tbb/detail/_task.h>
|
||||
|
||||
namespace AtmAdmin {
|
||||
|
||||
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";
|
||||
|
@ -23,11 +22,6 @@ namespace AtmAdmin {
|
|||
|
||||
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.
|
||||
// It should also enforce 4 numbers.
|
||||
|
||||
// The code below is a placeholder.
|
||||
tempInformation = changeAccountPin();
|
||||
if (tempInformation != "invalid") {
|
||||
information = tempInformation;
|
||||
|
@ -60,17 +54,16 @@ namespace AtmAdmin {
|
|||
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 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::cin >> newPin;
|
||||
Error::ignoreLine();
|
||||
|
@ -111,4 +104,18 @@ namespace AtmAdmin {
|
|||
|
||||
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