Interactive project developed in Java that simulates a Pokémon battle between a player and a machine, applying type effectiveness rules and attack statistics.
The player chooses their name, Pokémon type, attack value and HP. The machine automatically generates its own type, attack and HP using random values, making the battle unpredictable and fair.
Pokemon.java— abstract base class with shared attributes (type, name, attack, hp), battle logic and effectiveness calculation.Jugador.java— extends Pokemon, receives player data from user input.Maquina.java— extends Pokemon, generates its own stats randomly.Main.java— handles user input and controls the battle flow.
- Player name
- Pokémon type: (water, fire, grass, electric)
- Attack value (1-100)
- HP (1-100)
- OOP with inheritance: abstract class
Pokemonas base, extended byJugadorandMaquina. - Random machine: the machine generates its type, attack and HP automatically, preventing the player from having an unfair advantage.
- Type effectiveness: dynamic damage multiplier based on elemental strengths and weaknesses.
- Data validation: error handling for non-numeric inputs using try-catch and loops.
- Two battle rounds: player attacks machine, then machine attacks player.
--- Welcome to the Pokémon Battle Simulator ---
Enter your name: Ash
Choose your type (water, fire, grass, electric): fire
Enter attack value (1-100): 80
Enter your HP (1-100): 75
--- YOUR POKÉMON ---
Ash | Type: fire | Attack: 80 | HP: 75
--- MACHINE'S POKÉMON ---
Machine | Type: water | Attack: 65 | HP: 90
=== ROUND 1: You attack! ===
--- BATTLE RESULT ---
Attacker: fire | Defender: water
Effectiveness: x0.5
Total Damage: 40.00
Machine survives with 50.00 HP remaining.
=== ROUND 2: Machine attacks! ===
--- BATTLE RESULT ---
Attacker: water | Defender: fire
Effectiveness: x2.0
Total Damage: 130.00
Ash has fainted! Machine WINS!