Created
February 27, 2020 18:22
-
-
Save parzibyte/63d28c0618278290b504fb365a751175 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
____ _____ _ _ _ | |
| _ \ | __ \ (_) | | | | |
| |_) |_ _ | |__) |_ _ _ __ _____| |__ _ _| |_ ___ | |
| _ <| | | | | ___/ _` | '__|_ / | '_ \| | | | __/ _ \ | |
| |_) | |_| | | | | (_| | | / /| | |_) | |_| | || __/ | |
|____/ \__, | |_| \__,_|_| /___|_|_.__/ \__, |\__\___| | |
__/ | __/ | | |
|___/ |___/ | |
Blog: https://parzibyte.me/blog | |
Ayuda: https://parzibyte.me/blog/contrataciones-ayuda/ | |
Contacto: https://parzibyte.me/blog/contacto/ | |
Copyright (c) 2020 Luis Cabrera Benito | |
Licenciado bajo la licencia MIT | |
El texto de arriba debe ser incluido en cualquier redistribucion | |
*/ | |
public class Main { | |
public static void main(String[] args) { | |
String cadenasParaProbar[] = { "Mi hijo degustó en el festival de bayas una extraña pizza de kiwi con queso", | |
"Hola", | |
"El veloz murciélago hindú comía feliz cardillo y kiwi. La cigüeña tocaba el saxofón detrás del palenque de paja", | |
"ABCDEFGHIJKLMNÑOPQRSTUVWXYZ", // Debería ser true | |
"ABCDEFGHIJKLMNÑOPQRSTUVWXY", // Sin Z | |
}; | |
for (String cadena : cadenasParaProbar) { | |
System.out.printf("La cadena '%s' es pangrama? %b\n", cadena, esPangrama(cadena)); | |
} | |
} | |
public static boolean esPangrama(String cadena) { | |
cadena = cadena.toUpperCase(); // Convertir a mayúscula para simplificar comparaciones | |
String letrasDelAlfabeto = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZ"; | |
for (int x = 0; x < letrasDelAlfabeto.length(); x++) { | |
if (!cadena.contains(Character.toString(letrasDelAlfabeto.charAt(x)))) { | |
return false; | |
} | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment