Has hit points (HP), attack skills, and defensive skills. Can perform either an attack or defense action each turn. Uses random selection for choosing skills. Tracks whether it defended in the last turn to reduce damage.
Represents both attack and defense moves. Each skill has a name and power value.
Two Pokémon take turns attacking or defending. Damage is reduced if the defending Pokémon used a defense skill in the previous turn. Battle continues until one Pokémon's HP reaches 0.
The game starts by initializing two Pokémon, each with different attack and defense skills. Each Pokémon takes turns, either attacking or defending (randomly selected). If a Pokémon attacks, the opponent takes damage. If a Pokémon defends, it reduces the damage it takes during the next attack. The game continues until one Pokémon faints (HP reaches 0).
Compile and run the Java program. Watch as the two Pokémon battle, and press Enter between rounds to advance. The battle continues until one of the Pokémon wins. This simple implementation can be extended with more features, such as additional Pokémon, more complex attacks, and strategies.
The battle between Pikachu and Charmander begins! Pikachu attacks using Thunderbolt! Charmander takes 20 damage! Charmander attacks using Flamethrower! Pikachu takes 25 damage! Pikachu has 75 HP remaining. Charmander has 80 HP remaining. Press Enter to continue...
Pikachu defends using Electro Shield reducing next damage by 15! Charmander attacks using Scratch! Pikachu takes 0 damage after defense! Pikachu has 75 HP remaining. Charmander has 80 HP remaining. Press Enter to continue...
Pikachu defends using Agility Dodge reducing next damage by 10! Charmander attacks using Flamethrower! Pikachu takes 15 damage after defense! Pikachu has 60 HP remaining. Charmander has 80 HP remaining. Press Enter to continue...
Pikachu attacks using Quick Attack! Charmander takes 10 damage! Charmander attacks using Flamethrower! Pikachu takes 25 damage! Pikachu has 35 HP remaining. Charmander has 70 HP remaining. Press Enter to continue...
Pikachu defends using Electro Shield reducing next damage by 15! Charmander attacks using Flamethrower! Pikachu takes 10 damage after defense! Pikachu has 25 HP remaining. Charmander has 70 HP remaining. Press Enter to continue...
Pikachu attacks using Quick Attack! Charmander takes 10 damage! Charmander attacks using Scratch! Pikachu takes 10 damage! Pikachu has 15 HP remaining. Charmander has 60 HP remaining. Press Enter to continue...
Pikachu attacks using Thunderbolt! Charmander takes 20 damage! Charmander defends using Flame Guard reducing next damage by 12! Pikachu has 15 HP remaining. Charmander has 40 HP remaining. Press Enter to continue...
Pikachu defends using Electro Shield reducing next damage by 15! Charmander attacks using Flamethrower! Pikachu takes 10 damage after defense! Pikachu has 5 HP remaining. Charmander has 40 HP remaining. Press Enter to continue...
Pikachu attacks using Thunderbolt! Charmander takes 8 damage after defense! Charmander defends using Smoke Screen reducing next damage by 8! Pikachu has 5 HP remaining. Charmander has 32 HP remaining. Press Enter to continue...
Pikachu defends using Agility Dodge reducing next damage by 10! Charmander defends using Smoke Screen reducing next damage by 8! Pikachu has 5 HP remaining. Charmander has 32 HP remaining. Press Enter to continue...
Pikachu defends using Electro Shield reducing next damage by 15! Charmander defends using Smoke Screen reducing next damage by 8! Pikachu has 5 HP remaining. Charmander has 32 HP remaining. Press Enter to continue...
Pikachu attacks using Thunderbolt! Charmander takes 12 damage after defense! Charmander attacks using Scratch! Pikachu takes 0 damage after defense! Pikachu has 5 HP remaining. Charmander has 20 HP remaining. Press Enter to continue...
Pikachu attacks using Thunderbolt! Charmander takes 20 damage! Charmander has fainted! Pikachu wins the battle!