Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program Specifications: (Use Java, Create a menu to display all information in CSV, Using the same format modify the starter code to work for this

Program Specifications: (Use Java, Create a menu to display all information in CSV, Using the same format modify the starter code to work for this question, Please match code output to sample output at bottom of question)

The Pokdex is an electronic device designed to catalogue and provide information regarding the various species of Pokmon featured in the Pokmon video game, anime and manga series. (http://pokemon.wikia.com/wiki/Pok%C3%A9dex).

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 test/driver 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.

Notes: A common file format for data is a comma separated value file, or csv file. CSVs allow us to easily deal with spaces in the input data.

Pokemon CSV downloaded from: https://gist.github.com/armgilles/194bcff35001e7eb53a2a8b441e8b2c6

To Do:

Design and implement a Pokemon class

Implement appropriate setters and getters

Implement the toString() method

Optional: implement an overloaded constructor

Starter Code (Please modify this code to work for this assignment):

Main.java:

import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { ArrayList partslist = new ArrayList<>(); File componentInfoCSVfile = new File("week1review/classDemo.csv"); Scanner fileScanner = null; try { fileScanner = new Scanner(componentInfoCSVfile); while(fileScanner.hasNextLine()) { String componentInfoLine = fileScanner.nextLine(); String[] componentInfoSplit = componentInfoLine.split(","); String partName = componentInfoSplit[0]; double partPrice = Double.parseDouble(componentInfoSplit[1]); Component component = new Component(partName, partPrice); partslist.add(component); System.out.println(component.getName()); } for (int i = 0; i < partslist.size(); i++) { System.out.println(partslist.get(i)); } } catch (FileNotFoundException e) { System.out.println("Hey you lost your file!");; } } }

Component.java:

public class Component { private double price; private String name; public Component() { price = 100; this.name = "no name component"; } public Component(String name, double price) { this.price = price; this.name = name; } public double getPrice() { return price; } public void setPrice(double price) { this.price = price; } public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public String toString() { return "Component{" + "price=" + price + ", name='" + name + '\'' + '}'; } }

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_2

Step: 3

blur-text-image_3

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

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions

Question

Appreciate why organizational managers prefer to remain union-free

Answered: 1 week ago