SlideShare a Scribd company logo
1 of 13
Download to read offline
ArrayListOfObjects
Assignment 4:
100 points
due Thurs, Feb 23rd.
Adapt your ArrayOfPokemon code from assignment 2 to use the new Pokemon objects.
When adding a Pokemon, instead of making the user enter all the information, make a menu for
them to pick from the nine (or more) implemented species: (Bulbasaur, Ivysaur, Venusaur,
Charmander, Charmaleon, Charizard, Squirtle, Wartortle, Blastoise).The only thing the user must
choose is the species of Pokemon and if it gets a name.
If they want a name, then the program should ask them to enter one.
Then call the constructor for the chosen Pokemon. For example: Pokemon p = new Bulbasaur();
or Pokemon p = new Squirtle(sName);
Change the Array from assignment 2 to a Java API ArrayList.
For examples on using an ArrayList, see the uploaded sample code ArrayListDemo.java and
slide 40 of ICS211_Lecture09_ListsAndContainers.pdf on Laulima -> Resources -> Week 5.
Also see the Java API website for ArrayList for available methods.
The allowed number of stored Pokemon should still be limited to 6. Don't let the ArrayList keep
growing though it can!
Assignment 2 code is here,Please help me change it to match Assignment 4's requirement.
This is the Pokemon.java code.import java.util.*; //scannerpublic class PokeArray{static final int
SIZE = 6;public static void main(String[] args){Scanner userIn = new
Scanner(System.in);String inString = new String("");boolean endLoop = false;Pokemon[]
arrPoke = new Pokemon[SIZE];int nextIndex = 0; //points to index for next insert//loop until
stopping condition is givenwhile(endLoop != true){//menu textSystem.out.println("Please enter
the number of your choice:");System.out.println("1. Add a Pokemon");System.out.println("2.
Print all Pokemon");System.out.println("0. Exit the program");System.out.print("What
would you like to do? ");//read in from user as a String -- much less errors can happen!inString
= userIn.nextLine();//take off any spaces on the stringinString = inString.trim();//just switch on
the String no need to convert to intswitch(inString){case "0": endLoop =
true;System.out.println("Good bye!");break;case "1": //do stuff to make a new
PokemonarrPoke[nextIndex] = PokeArray.makePokemon();nextIndex = (nextIndex + 1)%
SIZE; //makes value run from 0-5 alwaysbreak;case "2": //print out all the
PokemonPokeArray.printArray(arrPoke);break;default: //not a valid menu
entrySystem.out.println(" ****Invalid menu choice.**** Please enter a 0, 1, or 2
");break;}}}//close main method/** makePokemon asks user for data for a new Pokemon
object and instantiates it** @return a Pokemon to insert into the array*/public static Pokemon
makePokemon(){Scanner userIn = new Scanner(System.in);Pokemon newPoke;//Data for new
Pokemon constructorString inName = new String("");String inNick = new String("");String
inNum = new String("");//have to convert to an intString inType1 = new String("");String
inType2 = new String("");int iNum = 0;boolean dataGood = false;//keep taking input until user
enters valid inputwhile(dataGood == false){//this can be used later when Pokemon exception is
made tootry{System.out.println("Enter the Pokemon's name:");inName =
userIn.nextLine();inName = inName.trim();System.out.println("Enter a nickname, or just enter
if none:");inNick = userIn.nextLine();inNick = inNick.trim();System.out.println("Enter the
Pokemon's number:");inNum = userIn.nextLine();inNum = inNum.trim();iNum =
Integer.parseInt(inNum); //parse into an intSystem.out.println("Enter the Pokemon's
type:");inType1 = userIn.nextLine();inType1 = inType1.trim();System.out.println("Enter the
Pokemon's second type, if none just enter:");inType2 = userIn.nextLine();inType2 =
inType2.trim();dataGood = true;}catch(NumberFormatException nfe){System.out.println("You
didn't enter a valid number, try again");}}if(inNick.length() > 0){//call 5 parameter
constructornewPoke = new Pokemon(inName, inNick, iNum, inType1, inType2);}else{//call
constructor without nicknamenewPoke = new Pokemon(inName, iNum, inType1,
inType2);}return newPoke;}/** printArray prints array of Pokemon* @param pArray an array
of Pokemon Objects*/public static void printArray(Pokemon[] pArray){for(int i = 0; i < SIZE;
i++){if(pArray[i] != null){//don't print the indicies that are not
filledSystem.out.println("Pokemon "+ i + ": ");
System.out.println(pArray[i].toString());}}}//end printArray method}
Solution
/*The main difference between Assignment2 and Assignment4 is implementation of ArrayList
and Inheritance*/
import java.util.*; //scanner
public class PokeArray{
static final int SIZE = 6;
public static void main(String[] args){
Scanner userIn = new Scanner(System.in);
String inString = new String("");
boolean endLoop = false;
ArrayList pokeList=new ArrayList(SIZE);
//loop until stopping condition is given
while(endLoop != true){
//menu text
System.out.println("Please enter the number of your choice:");
System.out.println("1. Add a Pokemon");
System.out.println("2. Print all Pokemon");
System.out.println("0. Exit the program");
System.out.print("What would you like to do? ");
//read in from user as a String -- much less errors can happen!
inString = userIn.nextLine();
//take off any spaces on the string
inString = inString.trim();
//just switch on the String no need to convert to int
switch(inString){
case "0": endLoop = true;
System.out.println("Good bye!");
break;
case "1": //do stuff to make a new Pokemon
pokeList.add(PokeArray.makePokemon());
break;
case "2": //print out all the Pokemon
PokeArray.printArray(pokeList);
break;
default: //not a valid menu entry
System.out.println(" ****Invalid menu choice.**** Please enter a 0, 1, or 2 ");
break;
}
}
}//close main method
/*
* makePokemon asks user for data for a new Pokemon object and instantiates it
*
* @return a Pokemon to insert into the array
*/
public static Pokemon makePokemon(){
Scanner userIn = new Scanner(System.in);
Pokemon newPoke;
//Data for new Pokemon constructor
String inName = new String("");
String inNick = new String("");
int iNum = 0;
boolean dataGood = false;
//keep taking input until user enters valid input
//this can be used later when Pokemon exception is made too
try{
System.out.println("Enter the Pokemon's name:");
inName = userIn.nextLine();
inName = inName.trim();
System.out.println("Enter a nickname, or just enter if none:");
inNick = userIn.nextLine();
inNick = inNick.trim();
if(inNick.length() > 0){//call 5 parameter constructor
if(inName=="Bulbasaur")
newPoke = new Bulbasaur(inNick);
else if(inName=="Ivysaur")
newPoke = new Ivysaur(inNick);
else if(inName=="Venusaur")
newPoke = new Venusaur(inNick);
else if(inName=="Charmander")
newPoke = new Charmander(inNick);
else if(inName=="Charmaleon")
newPoke = new Charmaleon(inNick);
else if(inName=="Charizard")
newPoke = new Charizard(inNick);
else if(inName=="Squirtle")
newPoke = new Squirtle(inNick);
else if(inName=="Wartotle")
newPoke = new Wartotle(inNick);
else if(inName=="Blastoise")
newPoke = new Blastoise(inNick);
else throw new Exception ();
}
else{//call constructor without nickname
if(inName=="Bulbasaur")
newPoke = new Bulbasaur();
else if(inName=="Ivysaur")
newPoke = new Ivysaur();
else if(inName=="Venusaur")
newPoke = new Venusaur();
else if(inName=="Charmander")
newPoke = new Charmander();
else if(inName=="Charmaleon")
newPoke = new Charmaleon();
else if(inName=="Charizard")
newPoke = new Charizard();
else if(inName=="Squirtle")
newPoke = new Squirtle();
else if(inName=="Wartotle")
newPoke = new Wartotle();
else if(inName=="Blastoise")
newPoke = new Blastoise();
else throw new Exception ();
}
}catch(Exception e){
System.out.println("Pokemon not found!! ");
}
return newPoke;
}
/*
* printArray prints array of Pokemon
* @param pArray an array of Pokemon Objects
*/
public static void printArray(ArrayList pArray){
Iterator itr=pArray.iterator();
//traversing elements of ArrayList object
while(itr.hasNext()){
Pokemon st=(Pokemon)itr.next();
System.out.println(st.toString());
}
}//end printArray method
}
Pokemon.java
import java.util.Random;
import java.text.*; //imports decimal format
public class Pokemon{
/** instance variables **/
/* the actual kind of Pokemon */
private String name;
/* optional user-defined name */
private String nickName;
/* official Pokemon number for Pokedex */
private int number;
/* required type of Pokemon */
private String type1;
/* optional second type */
private String type2;
/* interally calculated Hit Points */
private int HP;
/* internally calculated Combat Power */
private int CP;
/* main constructor with nickName and two types
* @param name official Pokemon name for this kind of Pokemon
* @param nickName user-given name or name if none
* @param number official Pokedex number for this Pokemon
* @param type1 the Pokemon type
* @param type2 second type if Pokemon has one, otherwise empty string
*/
public Pokemon(String name, String nickName, int number, String type1, String type2){
this.name = name;
this.nickName = nickName;
this.type1 = type1;
this.type2 = type2;
this.number = number;
initHPCP();
}
/* constructor with no nickname and two types
* calls other constructor with nickName set to name
* @param name the official Pokemon name for this kind of Pokemon
* @param number official Pokedex number for this Pokemon
* @param type1 the Pokemon type
* @param type2 second type if Pokemon has one
*/
/*
* private method for initializing HP and CP from constructors
*/
private void initHPCP(){
//generate random numbers
Random randGen = new Random();
int newHP;
int newCP;
double multiplier;
double CPrangeMin = 1.00;
double CPrangeMax = 3.00;
newHP = randGen.nextInt(141) + 10; //integer between 10 and 150 inclusive
this.HP = newHP;
multiplier = CPrangeMin + (CPrangeMax - CPrangeMin)*randGen.nextDouble();
this.CP = (int)(newHP*multiplier);
}
/*
* Returns Pokemon information as a formatted String
* @return String representing Pokemon object data
*/
public String toString( ){
DecimalFormat df = new DecimalFormat("000");
String s="";
s = "Name: " + this.name + " ";
if(this.name.compareTo(this.nickName) != 0){
s = s + "Nickname: " + this.nickName + " ";
}
s = s + "Number: " + df.format(this.number) + " ";
s = s + "Type: " + this.type1;
if(this.type2.length() > 0){
s = s + " | " + this.type2;
}
s = s+ " ";
s = s + "HP: " + this.HP + " ";
s = s + "CP: " + this.CP + " ";
return s;
}
/*
* updates a Pokemon's HP and CP
* CP only updated if random multiplier increases it
* otherwise it stays the same
*/
public void powerUp(){
Random randGen = new Random();
int newHP;
double multiplier;
double CPrangeMin = 1.00;
double CPrangeMax = 3.00;
this.HP = (int)(this.HP + 1.15 + (0.2*this.HP));//set HP using formula
multiplier = CPrangeMin + (CPrangeMax - CPrangeMin)*randGen.nextDouble();
if((this.HP * multiplier) > this.CP){
this.CP = (int)(this.HP * multiplier);
}
}
/** Get Methods **/
public String getName(){
return this.name;
}
public String getNickName(){
return this.nickName;
}
public String getType1(){
return this.type1;
}
public String getType2(){
return this.type2;
}
public int getNumber(){
return this.number;
}
public int getHP(){
return this.HP;
}
public int getCP() {
return this.CP;
}
/*
* only Nickname is user-settable
* @param String the new nickname for this Pokemon
*/
public void setNickName(String newNickName){
this.nickName = newNickName;
}
}
public class Bulbasaur extends Pokemon{
Bulbasaur()
{
super("Bulbasaur","Bulbasaur",1,"Grass","");
}
Bulbasaur(String sName)
{
super("Bulbasaur",sName,1,"Grass","");
}
}
public class Ivysaur extends Pokemon{
Ivysaur()
{
super("Ivysaur","Ivysaur",2,"Grass","");
}
Ivysaur(String sName)
{
super("Ivysaur",sName,2,"Grass","");
}
}
public class Venusaur extends Pokemon{
Venusaur()
{
super("Venusaur","Venusaur",3,"Grass","");
}
Venusaur(String sName)
{
super("Venusaur",sName,3,"Grass","");
}
}
public class Charmander extends Pokemon{
Charmander()
{
super("Charmander","Charmander",4,"Fire","");
}
Charmander(String sName)
{
super("Charmander",sName,4,"Fire","");
}
}
public class Charmaleon extends Pokemon{
Charmaleon()
{
super("Charmaleon","Charmaleon",5,"Fire","");
}
Charmaleon(String sName)
{
super("Charmaleon",sName,5,"Fire","");
}
}
public class Charizard extends Pokemon{
Charizard()
{
super("Charizard","Charizard",6,"Fire","");
}
Charizard(String sName)
{
super("Charizard",sName,6,"Fire","");
}
}
public class Squirtle extends Pokemon{
Squirtle()
{
super("Squirtle","Squirtle",7,"Water","");
}
Squirtle(String sName)
{
super("Squirtle",sName,7,"Water","");
}
}
public class Wartotle extends Pokemon{
Wartotle()
{
super("Wartotle","Wartotle",8,"Water","");
}
Wartotle(String sName)
{
super("Wartotle",sName,8,"Water","");
}
}
public class Blastoise extends Pokemon{
Blastoise()
{
super("Blastoise","Blastoise",9,"Water","");
}
Blastoise(String sName)
{
super("Blastoise",sName,9,"Water","");
}
}

More Related Content

Similar to ArrayListOfObjectsAssignment 4100 pointsdue Thurs, Feb 23rd..pdf

Integration Project Inspection 3
Integration Project Inspection 3Integration Project Inspection 3
Integration Project Inspection 3
Dillon Lee
 
mainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdfmainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdf
fathimafancyjeweller
 
question.(player, entity ,field and base.java codes are given)Stop.pdf
question.(player, entity ,field and base.java codes are given)Stop.pdfquestion.(player, entity ,field and base.java codes are given)Stop.pdf
question.(player, entity ,field and base.java codes are given)Stop.pdf
shahidqamar17
 
java write a program to evaluate the postfix expressionthe program.pdf
java write a program to evaluate the postfix expressionthe program.pdfjava write a program to evaluate the postfix expressionthe program.pdf
java write a program to evaluate the postfix expressionthe program.pdf
arjuntelecom26
 
Frequency .java Word frequency counter package frequ.pdf
Frequency .java  Word frequency counter  package frequ.pdfFrequency .java  Word frequency counter  package frequ.pdf
Frequency .java Word frequency counter package frequ.pdf
arshiartpalace
 
Here are the instructions and then the code in a sec. Please R.pdf
Here are the instructions and then the code in a sec. Please R.pdfHere are the instructions and then the code in a sec. Please R.pdf
Here are the instructions and then the code in a sec. Please R.pdf
aggarwalshoppe14
 
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdf
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdfRepeat Programming Project 2 in Chapter 5. This time, add the follow.pdf
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdf
arracollection
 
Tested on Eclipse and both class should be in same packageimport.pdf
Tested on Eclipse and both class should be in same packageimport.pdfTested on Eclipse and both class should be in same packageimport.pdf
Tested on Eclipse and both class should be in same packageimport.pdf
anuradhasilks
 
I really need some help if I have this right so far. PLEASE CHANG.pdf
I really need some help if I have this right so far. PLEASE CHANG.pdfI really need some help if I have this right so far. PLEASE CHANG.pdf
I really need some help if I have this right so far. PLEASE CHANG.pdf
aggarwalshoppe14
 
C# Program. Create a Windows application that has the functionality .pdf
C# Program. Create a Windows application that has the functionality .pdfC# Program. Create a Windows application that has the functionality .pdf
C# Program. Create a Windows application that has the functionality .pdf
fathimalinks
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdf
ARCHANASTOREKOTA
 
I really need some help if I have this right so far. Please Resub.pdf
I really need some help if I have this right so far. Please Resub.pdfI really need some help if I have this right so far. Please Resub.pdf
I really need some help if I have this right so far. Please Resub.pdf
aggarwalshoppe14
 
MIS 4310-01 Final Take Home Exam (100 points) DUE Thursd.docx
MIS 4310-01 Final Take Home Exam (100 points) DUE  Thursd.docxMIS 4310-01 Final Take Home Exam (100 points) DUE  Thursd.docx
MIS 4310-01 Final Take Home Exam (100 points) DUE Thursd.docx
raju957290
 
Please read the comment ins codeExpressionTree.java-------------.pdf
Please read the comment ins codeExpressionTree.java-------------.pdfPlease read the comment ins codeExpressionTree.java-------------.pdf
Please read the comment ins codeExpressionTree.java-------------.pdf
shanki7
 
Create a C# applicationYou are to create a class object called “Em.pdf
Create a C# applicationYou are to create a class object called “Em.pdfCreate a C# applicationYou are to create a class object called “Em.pdf
Create a C# applicationYou are to create a class object called “Em.pdf
feelingspaldi
 
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdfPLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
mallik3000
 
week3_srcDoWhileLoopFactorial.javaweek3_srcDoWhileLoopFactoria.docx
week3_srcDoWhileLoopFactorial.javaweek3_srcDoWhileLoopFactoria.docxweek3_srcDoWhileLoopFactorial.javaweek3_srcDoWhileLoopFactoria.docx
week3_srcDoWhileLoopFactorial.javaweek3_srcDoWhileLoopFactoria.docx
alanfhall8953
 
SeriesTester.classpathSeriesTester.project SeriesT.docx
SeriesTester.classpathSeriesTester.project  SeriesT.docxSeriesTester.classpathSeriesTester.project  SeriesT.docx
SeriesTester.classpathSeriesTester.project SeriesT.docx
lesleyryder69361
 

Similar to ArrayListOfObjectsAssignment 4100 pointsdue Thurs, Feb 23rd..pdf (20)

Integration Project Inspection 3
Integration Project Inspection 3Integration Project Inspection 3
Integration Project Inspection 3
 
mainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdfmainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdf
 
question.(player, entity ,field and base.java codes are given)Stop.pdf
question.(player, entity ,field and base.java codes are given)Stop.pdfquestion.(player, entity ,field and base.java codes are given)Stop.pdf
question.(player, entity ,field and base.java codes are given)Stop.pdf
 
java write a program to evaluate the postfix expressionthe program.pdf
java write a program to evaluate the postfix expressionthe program.pdfjava write a program to evaluate the postfix expressionthe program.pdf
java write a program to evaluate the postfix expressionthe program.pdf
 
Frequency .java Word frequency counter package frequ.pdf
Frequency .java  Word frequency counter  package frequ.pdfFrequency .java  Word frequency counter  package frequ.pdf
Frequency .java Word frequency counter package frequ.pdf
 
Here are the instructions and then the code in a sec. Please R.pdf
Here are the instructions and then the code in a sec. Please R.pdfHere are the instructions and then the code in a sec. Please R.pdf
Here are the instructions and then the code in a sec. Please R.pdf
 
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdf
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdfRepeat Programming Project 2 in Chapter 5. This time, add the follow.pdf
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdf
 
Tested on Eclipse and both class should be in same packageimport.pdf
Tested on Eclipse and both class should be in same packageimport.pdfTested on Eclipse and both class should be in same packageimport.pdf
Tested on Eclipse and both class should be in same packageimport.pdf
 
I really need some help if I have this right so far. PLEASE CHANG.pdf
I really need some help if I have this right so far. PLEASE CHANG.pdfI really need some help if I have this right so far. PLEASE CHANG.pdf
I really need some help if I have this right so far. PLEASE CHANG.pdf
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 
C# Program. Create a Windows application that has the functionality .pdf
C# Program. Create a Windows application that has the functionality .pdfC# Program. Create a Windows application that has the functionality .pdf
C# Program. Create a Windows application that has the functionality .pdf
 
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdf
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdfPrimeRange.java import java.util.Scanner;public class PrimeRan.pdf
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdf
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdf
 
I really need some help if I have this right so far. Please Resub.pdf
I really need some help if I have this right so far. Please Resub.pdfI really need some help if I have this right so far. Please Resub.pdf
I really need some help if I have this right so far. Please Resub.pdf
 
MIS 4310-01 Final Take Home Exam (100 points) DUE Thursd.docx
MIS 4310-01 Final Take Home Exam (100 points) DUE  Thursd.docxMIS 4310-01 Final Take Home Exam (100 points) DUE  Thursd.docx
MIS 4310-01 Final Take Home Exam (100 points) DUE Thursd.docx
 
Please read the comment ins codeExpressionTree.java-------------.pdf
Please read the comment ins codeExpressionTree.java-------------.pdfPlease read the comment ins codeExpressionTree.java-------------.pdf
Please read the comment ins codeExpressionTree.java-------------.pdf
 
Create a C# applicationYou are to create a class object called “Em.pdf
Create a C# applicationYou are to create a class object called “Em.pdfCreate a C# applicationYou are to create a class object called “Em.pdf
Create a C# applicationYou are to create a class object called “Em.pdf
 
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdfPLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
 
week3_srcDoWhileLoopFactorial.javaweek3_srcDoWhileLoopFactoria.docx
week3_srcDoWhileLoopFactorial.javaweek3_srcDoWhileLoopFactoria.docxweek3_srcDoWhileLoopFactorial.javaweek3_srcDoWhileLoopFactoria.docx
week3_srcDoWhileLoopFactorial.javaweek3_srcDoWhileLoopFactoria.docx
 
SeriesTester.classpathSeriesTester.project SeriesT.docx
SeriesTester.classpathSeriesTester.project  SeriesT.docxSeriesTester.classpathSeriesTester.project  SeriesT.docx
SeriesTester.classpathSeriesTester.project SeriesT.docx
 

More from fathimahardwareelect

using the knowledge about experiments that are related to plant g.pdf
using the knowledge about experiments that are related to plant g.pdfusing the knowledge about experiments that are related to plant g.pdf
using the knowledge about experiments that are related to plant g.pdf
fathimahardwareelect
 
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdfTHE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
fathimahardwareelect
 
Question 2 Sba Do you know something about the Statement Of Financ.pdf
Question 2 Sba Do you know something about the Statement Of Financ.pdfQuestion 2 Sba Do you know something about the Statement Of Financ.pdf
Question 2 Sba Do you know something about the Statement Of Financ.pdf
fathimahardwareelect
 
List and explain all the components of company culture.Jackson, S..pdf
List and explain all the components of company culture.Jackson, S..pdfList and explain all the components of company culture.Jackson, S..pdf
List and explain all the components of company culture.Jackson, S..pdf
fathimahardwareelect
 
Please write 5-6 setences about each emotional intelligence capabili.pdf
Please write 5-6 setences about each emotional intelligence capabili.pdfPlease write 5-6 setences about each emotional intelligence capabili.pdf
Please write 5-6 setences about each emotional intelligence capabili.pdf
fathimahardwareelect
 
Please help me find my errors. I am lost as I know what the problem.pdf
Please help me find my errors. I am lost as I know what the problem.pdfPlease help me find my errors. I am lost as I know what the problem.pdf
Please help me find my errors. I am lost as I know what the problem.pdf
fathimahardwareelect
 
Identify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdf
Identify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdfIdentify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdf
Identify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdf
fathimahardwareelect
 
How does Warhol add to the semiotic statement of the readymadeS.pdf
How does Warhol add to the semiotic statement of the readymadeS.pdfHow does Warhol add to the semiotic statement of the readymadeS.pdf
How does Warhol add to the semiotic statement of the readymadeS.pdf
fathimahardwareelect
 

More from fathimahardwareelect (20)

Which one of the following is NOT a social trend that is currently af.pdf
Which one of the following is NOT a social trend that is currently af.pdfWhich one of the following is NOT a social trend that is currently af.pdf
Which one of the following is NOT a social trend that is currently af.pdf
 
Which of the following is normally a major activity of materials man.pdf
Which of the following is normally a major activity of materials man.pdfWhich of the following is normally a major activity of materials man.pdf
Which of the following is normally a major activity of materials man.pdf
 
What is the role of civil society in promoting democracySolutio.pdf
What is the role of civil society in promoting democracySolutio.pdfWhat is the role of civil society in promoting democracySolutio.pdf
What is the role of civil society in promoting democracySolutio.pdf
 
What mechanism causes plant ion-uptake to acidify soilSolution.pdf
What mechanism causes plant ion-uptake to acidify soilSolution.pdfWhat mechanism causes plant ion-uptake to acidify soilSolution.pdf
What mechanism causes plant ion-uptake to acidify soilSolution.pdf
 
using the knowledge about experiments that are related to plant g.pdf
using the knowledge about experiments that are related to plant g.pdfusing the knowledge about experiments that are related to plant g.pdf
using the knowledge about experiments that are related to plant g.pdf
 
True or False Justify your answer.The concept of flooding is alwa.pdf
True or False Justify your answer.The concept of flooding is alwa.pdfTrue or False Justify your answer.The concept of flooding is alwa.pdf
True or False Justify your answer.The concept of flooding is alwa.pdf
 
True or False. If H is a subgroup of the group G then H is one of it.pdf
True or False.  If H is a subgroup of the group G then H is one of it.pdfTrue or False.  If H is a subgroup of the group G then H is one of it.pdf
True or False. If H is a subgroup of the group G then H is one of it.pdf
 
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdfTHE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
 
Immunizations that the elderly need to receive on a yearly basis inc.pdf
Immunizations that the elderly need to receive on a yearly basis inc.pdfImmunizations that the elderly need to receive on a yearly basis inc.pdf
Immunizations that the elderly need to receive on a yearly basis inc.pdf
 
Question 11 Scarcity means O people need to use marginal analysis to .pdf
Question 11 Scarcity means O people need to use marginal analysis to .pdfQuestion 11 Scarcity means O people need to use marginal analysis to .pdf
Question 11 Scarcity means O people need to use marginal analysis to .pdf
 
Question 2 Sba Do you know something about the Statement Of Financ.pdf
Question 2 Sba Do you know something about the Statement Of Financ.pdfQuestion 2 Sba Do you know something about the Statement Of Financ.pdf
Question 2 Sba Do you know something about the Statement Of Financ.pdf
 
Question 1. give the CC++ code that defines an empty 5 element arra.pdf
Question 1. give the CC++ code that defines an empty 5 element arra.pdfQuestion 1. give the CC++ code that defines an empty 5 element arra.pdf
Question 1. give the CC++ code that defines an empty 5 element arra.pdf
 
List and explain all the components of company culture.Jackson, S..pdf
List and explain all the components of company culture.Jackson, S..pdfList and explain all the components of company culture.Jackson, S..pdf
List and explain all the components of company culture.Jackson, S..pdf
 
Please write 5-6 setences about each emotional intelligence capabili.pdf
Please write 5-6 setences about each emotional intelligence capabili.pdfPlease write 5-6 setences about each emotional intelligence capabili.pdf
Please write 5-6 setences about each emotional intelligence capabili.pdf
 
Please help me find my errors. I am lost as I know what the problem.pdf
Please help me find my errors. I am lost as I know what the problem.pdfPlease help me find my errors. I am lost as I know what the problem.pdf
Please help me find my errors. I am lost as I know what the problem.pdf
 
Negligence and intentional torts are subject to civil litigation as .pdf
Negligence and intentional torts are subject to civil litigation as .pdfNegligence and intentional torts are subject to civil litigation as .pdf
Negligence and intentional torts are subject to civil litigation as .pdf
 
Incuded within the major CPI basket groups are various government-cha.pdf
Incuded within the major CPI basket groups are various government-cha.pdfIncuded within the major CPI basket groups are various government-cha.pdf
Incuded within the major CPI basket groups are various government-cha.pdf
 
Identify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdf
Identify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdfIdentify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdf
Identify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdf
 
How many grams of solid NaCN have to be added to 1.4 L of water to d.pdf
How many grams of solid NaCN have to be added to 1.4 L of water to d.pdfHow many grams of solid NaCN have to be added to 1.4 L of water to d.pdf
How many grams of solid NaCN have to be added to 1.4 L of water to d.pdf
 
How does Warhol add to the semiotic statement of the readymadeS.pdf
How does Warhol add to the semiotic statement of the readymadeS.pdfHow does Warhol add to the semiotic statement of the readymadeS.pdf
How does Warhol add to the semiotic statement of the readymadeS.pdf
 

Recently uploaded

Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answers
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 

ArrayListOfObjectsAssignment 4100 pointsdue Thurs, Feb 23rd..pdf

  • 1. ArrayListOfObjects Assignment 4: 100 points due Thurs, Feb 23rd. Adapt your ArrayOfPokemon code from assignment 2 to use the new Pokemon objects. When adding a Pokemon, instead of making the user enter all the information, make a menu for them to pick from the nine (or more) implemented species: (Bulbasaur, Ivysaur, Venusaur, Charmander, Charmaleon, Charizard, Squirtle, Wartortle, Blastoise).The only thing the user must choose is the species of Pokemon and if it gets a name. If they want a name, then the program should ask them to enter one. Then call the constructor for the chosen Pokemon. For example: Pokemon p = new Bulbasaur(); or Pokemon p = new Squirtle(sName); Change the Array from assignment 2 to a Java API ArrayList. For examples on using an ArrayList, see the uploaded sample code ArrayListDemo.java and slide 40 of ICS211_Lecture09_ListsAndContainers.pdf on Laulima -> Resources -> Week 5. Also see the Java API website for ArrayList for available methods. The allowed number of stored Pokemon should still be limited to 6. Don't let the ArrayList keep growing though it can! Assignment 2 code is here,Please help me change it to match Assignment 4's requirement. This is the Pokemon.java code.import java.util.*; //scannerpublic class PokeArray{static final int SIZE = 6;public static void main(String[] args){Scanner userIn = new Scanner(System.in);String inString = new String("");boolean endLoop = false;Pokemon[] arrPoke = new Pokemon[SIZE];int nextIndex = 0; //points to index for next insert//loop until stopping condition is givenwhile(endLoop != true){//menu textSystem.out.println("Please enter the number of your choice:");System.out.println("1. Add a Pokemon");System.out.println("2. Print all Pokemon");System.out.println("0. Exit the program");System.out.print("What would you like to do? ");//read in from user as a String -- much less errors can happen!inString = userIn.nextLine();//take off any spaces on the stringinString = inString.trim();//just switch on the String no need to convert to intswitch(inString){case "0": endLoop = true;System.out.println("Good bye!");break;case "1": //do stuff to make a new PokemonarrPoke[nextIndex] = PokeArray.makePokemon();nextIndex = (nextIndex + 1)% SIZE; //makes value run from 0-5 alwaysbreak;case "2": //print out all the PokemonPokeArray.printArray(arrPoke);break;default: //not a valid menu entrySystem.out.println(" ****Invalid menu choice.**** Please enter a 0, 1, or 2 ");break;}}}//close main method/** makePokemon asks user for data for a new Pokemon
  • 2. object and instantiates it** @return a Pokemon to insert into the array*/public static Pokemon makePokemon(){Scanner userIn = new Scanner(System.in);Pokemon newPoke;//Data for new Pokemon constructorString inName = new String("");String inNick = new String("");String inNum = new String("");//have to convert to an intString inType1 = new String("");String inType2 = new String("");int iNum = 0;boolean dataGood = false;//keep taking input until user enters valid inputwhile(dataGood == false){//this can be used later when Pokemon exception is made tootry{System.out.println("Enter the Pokemon's name:");inName = userIn.nextLine();inName = inName.trim();System.out.println("Enter a nickname, or just enter if none:");inNick = userIn.nextLine();inNick = inNick.trim();System.out.println("Enter the Pokemon's number:");inNum = userIn.nextLine();inNum = inNum.trim();iNum = Integer.parseInt(inNum); //parse into an intSystem.out.println("Enter the Pokemon's type:");inType1 = userIn.nextLine();inType1 = inType1.trim();System.out.println("Enter the Pokemon's second type, if none just enter:");inType2 = userIn.nextLine();inType2 = inType2.trim();dataGood = true;}catch(NumberFormatException nfe){System.out.println("You didn't enter a valid number, try again");}}if(inNick.length() > 0){//call 5 parameter constructornewPoke = new Pokemon(inName, inNick, iNum, inType1, inType2);}else{//call constructor without nicknamenewPoke = new Pokemon(inName, iNum, inType1, inType2);}return newPoke;}/** printArray prints array of Pokemon* @param pArray an array of Pokemon Objects*/public static void printArray(Pokemon[] pArray){for(int i = 0; i < SIZE; i++){if(pArray[i] != null){//don't print the indicies that are not filledSystem.out.println("Pokemon "+ i + ": "); System.out.println(pArray[i].toString());}}}//end printArray method} Solution /*The main difference between Assignment2 and Assignment4 is implementation of ArrayList and Inheritance*/ import java.util.*; //scanner public class PokeArray{ static final int SIZE = 6; public static void main(String[] args){
  • 3. Scanner userIn = new Scanner(System.in); String inString = new String(""); boolean endLoop = false; ArrayList pokeList=new ArrayList(SIZE); //loop until stopping condition is given while(endLoop != true){ //menu text System.out.println("Please enter the number of your choice:"); System.out.println("1. Add a Pokemon"); System.out.println("2. Print all Pokemon"); System.out.println("0. Exit the program"); System.out.print("What would you like to do? "); //read in from user as a String -- much less errors can happen! inString = userIn.nextLine(); //take off any spaces on the string inString = inString.trim(); //just switch on the String no need to convert to int switch(inString){ case "0": endLoop = true; System.out.println("Good bye!"); break; case "1": //do stuff to make a new Pokemon pokeList.add(PokeArray.makePokemon()); break; case "2": //print out all the Pokemon PokeArray.printArray(pokeList); break; default: //not a valid menu entry System.out.println(" ****Invalid menu choice.**** Please enter a 0, 1, or 2 "); break;
  • 4. } } }//close main method /* * makePokemon asks user for data for a new Pokemon object and instantiates it * * @return a Pokemon to insert into the array */ public static Pokemon makePokemon(){ Scanner userIn = new Scanner(System.in); Pokemon newPoke; //Data for new Pokemon constructor String inName = new String(""); String inNick = new String(""); int iNum = 0; boolean dataGood = false; //keep taking input until user enters valid input //this can be used later when Pokemon exception is made too try{ System.out.println("Enter the Pokemon's name:"); inName = userIn.nextLine(); inName = inName.trim(); System.out.println("Enter a nickname, or just enter if none:"); inNick = userIn.nextLine(); inNick = inNick.trim(); if(inNick.length() > 0){//call 5 parameter constructor if(inName=="Bulbasaur") newPoke = new Bulbasaur(inNick); else if(inName=="Ivysaur") newPoke = new Ivysaur(inNick); else if(inName=="Venusaur")
  • 5. newPoke = new Venusaur(inNick); else if(inName=="Charmander") newPoke = new Charmander(inNick); else if(inName=="Charmaleon") newPoke = new Charmaleon(inNick); else if(inName=="Charizard") newPoke = new Charizard(inNick); else if(inName=="Squirtle") newPoke = new Squirtle(inNick); else if(inName=="Wartotle") newPoke = new Wartotle(inNick); else if(inName=="Blastoise") newPoke = new Blastoise(inNick); else throw new Exception (); } else{//call constructor without nickname if(inName=="Bulbasaur") newPoke = new Bulbasaur(); else if(inName=="Ivysaur") newPoke = new Ivysaur(); else if(inName=="Venusaur") newPoke = new Venusaur(); else if(inName=="Charmander") newPoke = new Charmander(); else if(inName=="Charmaleon") newPoke = new Charmaleon(); else if(inName=="Charizard") newPoke = new Charizard(); else if(inName=="Squirtle") newPoke = new Squirtle(); else if(inName=="Wartotle") newPoke = new Wartotle(); else if(inName=="Blastoise") newPoke = new Blastoise(); else throw new Exception (); }
  • 6. }catch(Exception e){ System.out.println("Pokemon not found!! "); } return newPoke; } /* * printArray prints array of Pokemon * @param pArray an array of Pokemon Objects */ public static void printArray(ArrayList pArray){ Iterator itr=pArray.iterator(); //traversing elements of ArrayList object while(itr.hasNext()){ Pokemon st=(Pokemon)itr.next(); System.out.println(st.toString()); } }//end printArray method } Pokemon.java import java.util.Random; import java.text.*; //imports decimal format public class Pokemon{ /** instance variables **/ /* the actual kind of Pokemon */ private String name; /* optional user-defined name */ private String nickName; /* official Pokemon number for Pokedex */ private int number;
  • 7. /* required type of Pokemon */ private String type1; /* optional second type */ private String type2; /* interally calculated Hit Points */ private int HP; /* internally calculated Combat Power */ private int CP; /* main constructor with nickName and two types * @param name official Pokemon name for this kind of Pokemon * @param nickName user-given name or name if none * @param number official Pokedex number for this Pokemon * @param type1 the Pokemon type * @param type2 second type if Pokemon has one, otherwise empty string */ public Pokemon(String name, String nickName, int number, String type1, String type2){ this.name = name; this.nickName = nickName; this.type1 = type1; this.type2 = type2; this.number = number; initHPCP(); } /* constructor with no nickname and two types * calls other constructor with nickName set to name * @param name the official Pokemon name for this kind of Pokemon * @param number official Pokedex number for this Pokemon * @param type1 the Pokemon type * @param type2 second type if Pokemon has one */ /*
  • 8. * private method for initializing HP and CP from constructors */ private void initHPCP(){ //generate random numbers Random randGen = new Random(); int newHP; int newCP; double multiplier; double CPrangeMin = 1.00; double CPrangeMax = 3.00; newHP = randGen.nextInt(141) + 10; //integer between 10 and 150 inclusive this.HP = newHP; multiplier = CPrangeMin + (CPrangeMax - CPrangeMin)*randGen.nextDouble(); this.CP = (int)(newHP*multiplier); } /* * Returns Pokemon information as a formatted String * @return String representing Pokemon object data */ public String toString( ){ DecimalFormat df = new DecimalFormat("000"); String s=""; s = "Name: " + this.name + " "; if(this.name.compareTo(this.nickName) != 0){ s = s + "Nickname: " + this.nickName + " "; } s = s + "Number: " + df.format(this.number) + " "; s = s + "Type: " + this.type1; if(this.type2.length() > 0){ s = s + " | " + this.type2; } s = s+ " ";
  • 9. s = s + "HP: " + this.HP + " "; s = s + "CP: " + this.CP + " "; return s; } /* * updates a Pokemon's HP and CP * CP only updated if random multiplier increases it * otherwise it stays the same */ public void powerUp(){ Random randGen = new Random(); int newHP; double multiplier; double CPrangeMin = 1.00; double CPrangeMax = 3.00; this.HP = (int)(this.HP + 1.15 + (0.2*this.HP));//set HP using formula multiplier = CPrangeMin + (CPrangeMax - CPrangeMin)*randGen.nextDouble(); if((this.HP * multiplier) > this.CP){ this.CP = (int)(this.HP * multiplier); } } /** Get Methods **/ public String getName(){ return this.name; } public String getNickName(){ return this.nickName; } public String getType1(){ return this.type1; }
  • 10. public String getType2(){ return this.type2; } public int getNumber(){ return this.number; } public int getHP(){ return this.HP; } public int getCP() { return this.CP; } /* * only Nickname is user-settable * @param String the new nickname for this Pokemon */ public void setNickName(String newNickName){ this.nickName = newNickName; } } public class Bulbasaur extends Pokemon{ Bulbasaur() { super("Bulbasaur","Bulbasaur",1,"Grass",""); } Bulbasaur(String sName) { super("Bulbasaur",sName,1,"Grass",""); } } public class Ivysaur extends Pokemon{ Ivysaur() { super("Ivysaur","Ivysaur",2,"Grass",""); }
  • 11. Ivysaur(String sName) { super("Ivysaur",sName,2,"Grass",""); } } public class Venusaur extends Pokemon{ Venusaur() { super("Venusaur","Venusaur",3,"Grass",""); } Venusaur(String sName) { super("Venusaur",sName,3,"Grass",""); } } public class Charmander extends Pokemon{ Charmander() { super("Charmander","Charmander",4,"Fire",""); } Charmander(String sName) { super("Charmander",sName,4,"Fire",""); } } public class Charmaleon extends Pokemon{ Charmaleon() { super("Charmaleon","Charmaleon",5,"Fire",""); } Charmaleon(String sName) { super("Charmaleon",sName,5,"Fire",""); } } public class Charizard extends Pokemon{
  • 12. Charizard() { super("Charizard","Charizard",6,"Fire",""); } Charizard(String sName) { super("Charizard",sName,6,"Fire",""); } } public class Squirtle extends Pokemon{ Squirtle() { super("Squirtle","Squirtle",7,"Water",""); } Squirtle(String sName) { super("Squirtle",sName,7,"Water",""); } } public class Wartotle extends Pokemon{ Wartotle() { super("Wartotle","Wartotle",8,"Water",""); } Wartotle(String sName) { super("Wartotle",sName,8,"Water",""); } } public class Blastoise extends Pokemon{ Blastoise() { super("Blastoise","Blastoise",9,"Water",""); } Blastoise(String sName) {