#include "enter_name.h" #include // for max, min // Constructor EnterName::EnterName(std::string *name) { // Obtiene el puntero al nombre this->name = name; // Inicia la lista de caracteres permitidos characterList = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; pos = 0; numCharacters = (int)characterList.size(); for (int i = 0; i < NAME_LENGHT; ++i) { characterIndex[i] = 0; } } // Destructor EnterName::~EnterName() { } // Incrementa la posición void EnterName::incPos() { pos++; pos = std::min(pos, NAME_LENGHT - 1); } // Decrementa la posición void EnterName::decPos() { pos--; pos = std::max(pos, 0); } // Incrementa el índice void EnterName::incIndex() { ++characterIndex[pos]; if (characterIndex[pos] >= numCharacters) { characterIndex[pos] = 0; } } // Decrementa el índice void EnterName::decIndex() { --characterIndex[pos]; if (characterIndex[pos] < 0) { characterIndex[pos] = numCharacters - 1; } } // Actualiza la variable void EnterName::updateName() { name->clear(); for (int i = 0; i < NAME_LENGHT; ++i) { name->push_back(characterList[characterIndex[i]]); } }