Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Class 1 : Pokemon.java Description: Holds important data about a certain Pok mon . A Pok mon should have a ( String ) name /
Class : Pokemon.java
Description: Holds important data about a certain Pokmon A Pokmon should have a String namespeciesint level, int unique ID a list of String types, and a list of String moves. For example, the Pokmon Pikachu is an Electric type that has moves it can do such as Thunderbolt and Quick Attack. The list of types and list of moves can be implemented as either partially filled arrays or Java ArrayLists.
The Pokmon class should also contain a class variable to keep track of unique Pokmon IDs. Pokmon IDs should start at and increase by for each new Pokmon object created. Thus, the first Pokmon should have ID the second should have ID the third should have ID
Methods:
Your Pokmon class should contain a constructor that takes in parameters: the species, the level, and the two lists of types and moves.
a toString that prints out the Pokmons data.
any additional methods you may need
Main Class and Main method
Description: The primary job of the main method is to print out a text menu for users to choose an operation from and perform these operations. After choosing and following through with the operation, this menu should keep printing until the user decides to quit. The user has options to choose from: they can "catch" a new Pokmon print all Pokmon stored in their PC storage, delete a Pokmon from their PC storage, print the journal page of a specific Pokmon or quit the program. Your main class should contain ArrayLists. One of type String to keep track of the titles of journal pages, and one of the Object type Pokmon to hold the Pokmon that the user has caught in their PC Your main class should also contain a String constant for the name of a single txt input file.
At the start of the program, the main method should also read in the predetermined input txt file and count how many lines are in this file. This number of lines will be used when performing the catch a new Pokmon operation. If the file is empty has lines OR every line is empty your program should throw an IO Exception and print a custom message: No Pokmon found in this area, please try your Pokmon journey elsewhere!" before terminating the program.
The following is the general expected output for printing the menu:
Catch a new Pokemon
Print all Pokemon in PC
Delete a Pokemon from PC
Print Pokemon Info from Journal
Quit
What would you like to do
The user input should readin a single character String from If any other input is entered, the program should handle this by printing an appropriate message.
Catching a new Pokmon
Description: A Pokmon Trainer can catch a new Pokmon Your program should implement this by picking a random number from to the amount of lines you counted earlier in the program. Whatever random number is chosen, you should go to this line in the same given txt file and read in that line to catch that Pokmon
Lines in the txt Pokmon files will be given in the following format:
Pikachu, Electric : Quick Attack, Thunderbolt
ie the name of the Pokmon the Pokmons level, and the Pokmons types all separated by commas, followed by a colon, and then the Pokmons moves again separated by commas.
Upon reading in this line, the program should check if this is a new Pokmon to be added to the list of journal pages via its name. If it is a new Pokmon a new String file name should be added to the ArrayList of journal pages printing the information of the Pokmons namespecies types and moves. If it is not a new Pokmon the txt file for that Pokmon should add any new moves that the Pokmon has by appending them to the file.
After this, the program should ask the user if they would like to keep this Pokmon add it to their PC or not. If the user says yes, A new Pokmon Object should be created with this Pokmons data that was readin from the file and added to the ArrayList of Pokmon Objects the user's PC along with an appropriate update message.
File Input Errors:
The input.txt file may have the following errors:
A line in the input.txt file can be empty. If the line is empty, the message "failed to catch a Pokmon should be printed.
A line in the input.txt file can accidentally have no Pokmon moves! If a Pokmon has no moves, this should be checked in the constructor for the Pokmon class and throw an "IllegalStateException" to be caught in the main method. If this exception is incurred, a new Pokmon with this same data should be created but with a single Pokmon move "Struggle".
You may assume that all other inputdata from this file is always valid for this assignment.
An example of some sample output when trying to catch a Pokmon:
You caught a level Pikachu!
This is a new Pokemon, a new journal page will be added.
Would you like to keep the caught Pokemon yn
Uh oh Th
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started