Skip to content

Melycode/Pokemon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pokemon Battle Simulator (Java)

Interactive project developed in Java that simulates a Pokémon battle between a player and a machine, applying type effectiveness rules and attack statistics.

Description

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.

Project Structure

  • 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.

Input Variables

  • Player name
  • Pokémon type: (water, fire, grass, electric)
  • Attack value (1-100)
  • HP (1-100)

Features

  • OOP with inheritance: abstract class Pokemon as base, extended by Jugador and Maquina.
  • 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.

Sample Output

--- 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!

About

Pokemon Battle Simulator in Java — OOP with inheritance, type effectiveness and random machine opponent.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages