Continuem estandaritzant noms

This commit is contained in:
2024-10-11 13:54:43 +02:00
parent e1fa1d2102
commit a9ca23138d
15 changed files with 866 additions and 849 deletions

View File

@@ -11,12 +11,12 @@ EnterName::EnterName()
void EnterName::init()
{
// Obtiene el puntero al nombre
name = "A";
name_ = "A";
// Inicia la lista de caracteres permitidos
characterList = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-+-*/=?¿<>!\"#$%&/()";
pos = 0;
numCharacters = (int)characterList.size();
character_list_ = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-+-*/=?¿<>!\"#$%&/()";
pos_ = 0;
num_characters_ = (int)character_list_.size();
// Pone la lista de indices para que refleje el nombre
updateCharacterIndex();
@@ -28,24 +28,24 @@ void EnterName::init()
// Incrementa la posición
void EnterName::incPos()
{
pos++;
pos = std::min(pos, NAME_LENGHT - 1);
pos_++;
pos_ = std::min(pos_, NAME_LENGHT - 1);
}
// Decrementa la posición
void EnterName::decPos()
{
pos--;
pos = std::max(pos, 0);
pos_--;
pos_ = std::max(pos_, 0);
}
// Incrementa el índice
void EnterName::incIndex()
{
++characterIndex[pos];
if (characterIndex[pos] >= numCharacters)
++character_index_[pos_];
if (character_index_[pos_] >= num_characters_)
{
characterIndex[pos] = 0;
character_index_[pos_] = 0;
}
updateName();
}
@@ -53,10 +53,10 @@ void EnterName::incIndex()
// Decrementa el índice
void EnterName::decIndex()
{
--characterIndex[pos];
if (characterIndex[pos] < 0)
--character_index_[pos_];
if (character_index_[pos_] < 0)
{
characterIndex[pos] = numCharacters - 1;
character_index_[pos_] = num_characters_ - 1;
}
updateName();
}
@@ -64,10 +64,10 @@ void EnterName::decIndex()
// Actualiza la variable
void EnterName::updateName()
{
name.clear();
name_.clear();
for (int i = 0; i < NAME_LENGHT; ++i)
{
name.push_back(characterList[characterIndex[i]]);
name_.push_back(character_list_[character_index_[i]]);
}
}
@@ -77,22 +77,22 @@ void EnterName::updateCharacterIndex()
// Rellena de espacios
for (int i = 0; i < NAME_LENGHT; ++i)
{
characterIndex[i] = 0;
character_index_[i] = 0;
}
// Coloca los índices en funcion de los caracteres que forman el nombre
for (int i = 0; i < (int)name.size(); ++i)
for (int i = 0; i < (int)name_.size(); ++i)
{
characterIndex[i] = findIndex(name.at(i));
character_index_[i] = findIndex(name_.at(i));
}
}
// Encuentra el indice de un caracter en "characterList"
// Encuentra el indice de un caracter en "character_list_"
int EnterName::findIndex(char character)
{
for (int i = 0; i < (int)characterList.size(); ++i)
for (int i = 0; i < (int)character_list_.size(); ++i)
{
if (character == characterList[i])
if (character == character_list_[i])
{
return i;
}
@@ -103,11 +103,11 @@ int EnterName::findIndex(char character)
// Obtiene el nombre
std::string EnterName::getName() const
{
return name;
return name_;
}
// Obtiene la posición que se está editando
int EnterName::getPos() const
{
return pos;
return pos_;
}