Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can you add on to the following starter code to complete this task? You are tasked with writing a simple Pokedex program that will get
Can you add on to the following starter code to complete this task?
You are tasked with writing a simple Pokedex program that will get the information from a large list of pokemon stored in a file, save each pokemons information into pokemon objects within an ArrayList object.
Write a testdriver program that imports and processes the information from the pokemon CSV file. Additionally, write a simple, menu driven program that can display all pokemon, or find a specific pokemon by name.
To Do:
Design and implement a Pokemon class
Implement appropriate setters and getters
Implement the toString method
Optional: implement an overloaded constructor
Starter Code:
import java.ioFile;
import java.ioFileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
public class PokedexAssignment
static ArrayList mypokedex new ArrayList;
public static void mainString args
file reading review
absoluterelative paths
String filepath "pokedex.csv;
File pokedexFile new Filefilepath;
try
Scanner fileinput new ScannerpokedexFile;
throw away first line
fileinput.nextLine;
whilefileinputhasNextLine true
String lineInfo fileinput.nextLine;
String lineInfoSplit lineInfo.split;
:#
: Name
: Type
: Type
: Total
: HP
: Attack
: Defense
: Sp Atk
: Sp Def
: Speed
: Generation
: Legendary
Pokemon tempPoke new Pokemon;
tempPoke.setIdIntegerparseIntlineInfoSplit;
tempPoke.setNamelineInfoSplit;
System.out.printlnlineInfo;
mypokedex.addtempPoke;
System.out.println
Printing out the arraylist contents:";
System.out.printlnmypokedex;
catch FileNotFoundException e
System.out.printlne;
public class Pokemon
private int id;
private String name;
public Pokemon
public Pokemonint id String name
this.id id;
this.name name;
public int getId
return id;
public void setIdint id
this.id id;
public String getName
return name;
public void setNameString name
this.name name;
@Override
public String toString
return "Pokemon
id id
name name
;
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