/* Note: This code is very messy and does not follow great style Please do not follow this code as an example for classes you may write Hello there! Welcome to the world of Pokemon! My name is Oak! People call me the Pokemon Prof! This world is inhabited by creatures called Pokemon! For some people, Pokemon are pets. Other use them for fights. Every Pokemon has either 1 or 2 types. Each type can be "super-effective" against other types, similar to rock-paper-scissors. They also stats for various categories, what generation of the video game they were introduced, and whether or not it is a legendary pokemon. */ import java.util.*; public class Pokemon { public int number; public String name; public String type1; public String type2; public int totalStats; public int hp; public int attack; public int defense; public int specialAttack; public int specialDefense; public int speed; public int generation; public boolean legendary; // Takes in a comma separated line of data for a // Pokemon and constructs an instance of it with // the proper fields assigned public Pokemon(String info) { String[] stats = info.split(","); number = Integer.parseInt(stats[0]); name = stats[1]; type1 = stats[2]; type2 = stats[3]; totalStats = Integer.parseInt(stats[4]); hp = Integer.parseInt(stats[5]); attack = Integer.parseInt(stats[6]); defense = Integer.parseInt(stats[7]); specialAttack = Integer.parseInt(stats[8]); specialDefense = Integer.parseInt(stats[9]); speed = Integer.parseInt(stats[10]); generation = Integer.parseInt(stats[11]); legendary = stats[12].equals("True"); } // Returns the type(s) of the Pokemon as a String // eg. "Fire" or "Electric/Water" public String getType() { if (type2.isEmpty()) { return type1; } else { return type1 + "/" + type2; } } }