Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Files to Submit: RunPokemon.java Pokemon are little creatures who are raised by trainers and battle each other. They have a type and statistics including HP

Files to Submit:

RunPokemon.java

Pokemon are little creatures who are raised by trainers and battle each other. They have a type and statistics including HP (Health Points or Hit Points), Attack, Defense, Special Attack, Special Defense, and Speed.

A Pokemon can have one or two types. The different types are Normal, Ice, Psychic, Fire, Fighting, Bug, Dark, Water, Poison, Rock, Steel, Electric, Ground, Ghost, Fairy, Grass, Flying, and Dragon. A Pokemons type gives it both strengths and weaknesses in attack and defense in battle.

Pokemon also have statistics including the following:

HP the amount of damage a Pokemon can receive in battle before fainting.

Attack how much damage a Pokemon deals using a physical move.

Defense how much damage a Pokemon receives when hit with a physical move.

Special Attack how much damage a Pokemon deals when using a special move.

Special Defense how much damage a Pokemon receives when hit with a physical move.

Speed determines which Pokemon attacks first in a battle.

These statistics determine how effective a Pokemon will be in battle.

RunPokemon class

Your program will use a loop to read data from an input file and print a summary to an output file for a number of Pokemon characters. A sample file will be provided but a different file will be used to grade your project.

Input file

The input file will be called pokemon.txt. Hard code this value into your program. The input file will contain a number of sets of data for Pokemon characters. It will follow this format:

Pokemon name - String

Type - String

HP - int

Attack - int

Defense - int

Special Attack - int

Special Defense - int

Speed - int

The input file provided contains 5 sets of data, but the file used to grade your program will contain a different number of sets. As long as your while loop continues to loop while there is data in the input file, the amount of sets of the data in your input file will not matter.

Main method

Your RunPokemon class will contain a main method.

First declare any needed variables. The variables you will need include a PrintWriter object for the output file, a File and Scanner object for the input file, and variables to contain the 8 items of data you will read from the input file (2 String and 6 int variables use the words/phrases above to name your variables). You will also need an int variable called total.

Check if the input file exists. If it doesnt exist, end the program. If the input file exists, a Scanner object will be initialized with this file.

Create a PrintWriter object; call the output file PokemonSummary.txt.

Create a while loop that loops while there is more data in the input file. Inside the loop, read the 8 items of data using next() and nextInt() and store the values in their appropriate variables. Then, store the sum of the 6 int values (HP, Attack, Defense, Special Attack, Special Defense, Speed) in the variable called total. Total is important because the higher the total, the more potential that Pokemon will have in battle. The last step of the while loop is to print to the output file. On one line, print the name of the Pokemon, its type, and the total to the output file.

After the while loop completes, close the input and output files.

Using the input file provided, the output file should look as follows:

image text in transcribed

Pokemon.txt contents below.

Moltres Fire 90 100 90 125 85 90 Meowth Normal 40 45 35 40 40 90 Jigglypuff Fairy 115 45 20 45 25 20 Bulbasaur Grass 45 49 49 65 65 45 Pikachu Electric 35 55 40 50 50 90

Moltres Fire 580 Meowth Normal 290 Jigglypuff. Fairy 270 Bulbasaur Grass 318 Pikachu Electric 320

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Apache Cassandra Development

Authors: Vivek Mishra

1st Edition

1484201426, 9781484201428

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago