import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Random;
import org.json.JSONObject;
public class RandomPokemon {
public static void main(String[] args) {
try {
// Initialize HTTP Client
HttpClient client = HttpClient.newHttpClient();
// Generate a random Pokémon ID between 1 and 898 (number of Pokémon in the first 8 generations)
int randomPokemonId = new Random().nextInt(898) + 1;
// Create a request to the PokeAPI
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://pokeapi.co/api/v2/pokemon/" + randomPokemonId))
.build();
// Send the request and get the response
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
// Parse the response to JSON
JSONObject jsonObject = new JSONObject(response.body());
// Get the Pokémon name
String pokemonName = jsonObject.getString("name");
// Print the Pokémon name
System.out.println("Random Pokémon: " + pokemonName);
} catch (Exception e) {
e.printStackTrace();
}
}
}Ingeniero en Sistemas con maestría en Seguridad Informática. Era feliz programando hasta que fui víctima de un ataque. En aquella época no había mucho contenido de defensa, así que aprendí a atacar para luego entender cómo defender.
Freelance en desarrollo de software. Seguridad en entornos financieros (Penetration Testing, Phishing, Code Reviews). Desarrollo seguro de software.
Presentación individual ¿Experiencia previa? Lenguajes de programación
Traten de no faltar a las sesiones.
Las tareas no serán extensas, por eso les pido puntualidad en las entregas. Serán definidas de lunes a lunes. Solamente se hará excepciones en casos de fuerza mayor. “Tenía mucho trabajo” o “Jugaba el ídolo” no es fuerza mayor. Esta semana no tendremos tarea.
Las semanas empiezan los lunes
Sobre foros interactivos
Sobre los examenes (Proctorizer y Mesa de Ayuda)
Sobre las copias y ChatGPT ó similares en tareas
Por favor, si voy muy rápido o no entienden, no tengan vergüenza en avisarme.
Lo contrario también aplica, si se están aburriendo con contenido muy básico, avísenme.
Mi meta es que se diviertan aprendiendo.