Answered step by step
Verified Expert Solution
Link Copied!

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 1: Pokemon.java
Description: Holds important data about a certain Pokmon. A Pokmon should have a (String) name/species,(int) level, (int) unique ID, a list of 1-2(String) types, and a list of 1-4(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 10000 and increase by 1 for each new Pokmon object created. Thus, the first Pokmon should have ID 10000, the second should have ID 10001, the third should have ID 10002.......
Methods:
Your Pokmon class should contain a constructor that takes in 4 parameters: the species, the level, and the two lists of types and moves.
a toString() that prints out the Pokmon's 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 5 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 2 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 0 lines OR every line is empty), your program should throw an I/O 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:
1- Catch a new Pokemon
2- Print all Pokemon in PC
3- Delete a Pokemon from PC
4- Print Pokemon Info from Journal
5- Quit
What would you like to do (1-5)?
The user input should read-in a single character String from 1-5. 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 1 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, 5, Electric : Quick Attack, Thunderbolt
i.e. the name of the Pokmon, the Pokmon's level, and the Pokmon's 1-2 types all separated by commas, followed by a colon, and then the Pokmon's 1-4 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 Pokmon's name/species, type(s), 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 Pokmon's data that was read-in 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 input/data 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 5 Pikachu!
This is a new Pokemon, a new journal page will be added.
Would you like to keep the caught Pokemon (y/n)?
Uh oh! Th

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

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

24. Why is it important to correct astigmatism earlypg109

Answered: 1 week ago

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago