CB100

Notas, resueltos y tps de la materia Algoritmos y Estructuras de Datos
Index Commits Files Refs README
commit 34de47478e6a8e462b752333a57357b2488f07a7
parent f594cd05ac3ba92a9212cf862e8f7aba064f72d7
Author: Martin Kloeckner <mjkloeckner@gmail.com>
Date:   Sun, 23 Jun 2024 14:54:56 -0300

add aux func `strToLowercase` and search `Barrio` names case insensitive

Diffstat:
Mmenu.cpp | 12+++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/menu.cpp b/menu.cpp
@@ -8,6 +8,7 @@
 #include <vector>
 #include <cmath>
 #include <iomanip>
+#include <cctype>
 
 double getDistancia(double x1, double y1, double x2, double y2);
 
@@ -182,6 +183,15 @@ Menu::Menu() {
     this->coordX = this->coordY = 0.0f;
 }
 
+std::string strToLowercase(std::string str) {
+    std::string res;
+    for(size_t i = 0; i < str.size(); ++i) {
+        res += std::tolower(str[i]);
+    }
+
+    return res;
+}
+
 void delSurroundingChar(std::string &str, char c) {
     str.erase(0, 1);
     str[str.size() - 1] = '\0';
@@ -252,7 +262,7 @@ Barrio *Menu::getBarrioPorNombre(std::string nombre) {
 
     while(this->barrios->forwardCursor()) {
         barrio = this->barrios->getCursorData();
-        if(barrio->getNombre() == nombre) {
+        if(strToLowercase(barrio->getNombre()) == strToLowercase(nombre)) {
             res = this->barrios->getCursorData();
             break;
         }