SlideShare a Scribd company logo
import java.util.ArrayList;
//import java.util.Iterator;
/**
* A PokemonSpecies entry in the Pokedex. Maintains the number of candies associated
* with the Pokemon species as well as the Trainer's inventory of Pokemon of this
* species.
*/
public class PokemonSpecies {
private int pokedexNumber;
private String speciesName;
private int candies;
/**
* Maintains the list of Pokemon of this species in the Trainer's inventory.
*/
private ArrayList caughtPokemon;
/**
* Constructor suitable for a newly encountered Pokemon species during the course of the
* game and for loading species data from a save file.
*
*/
public PokemonSpecies(int pokedexNumber, String speciesName, int candies) {
this.pokedexNumber = pokedexNumber;
this.speciesName = speciesName;
this.candies = candies;
// construct caughtPokemon
caughtPokemon = new ArrayList();
}
/**
* Getter methods
*/
public Integer getPokedexNumber() {
return pokedexNumber;
}
public String getSpeciesName() {
return speciesName;
}
public int getCandies() {
return candies;
}
/**
* Add a newly caught Pokemon to the player's inventory and
* increase the number of candies for this PokemonSpecies
*
* @param pokemon the newly caught Pokemon
*/
public void addNewPokemon(Pokemon pokemon) {
caughtPokemon.add(pokemon);
this.addNewPokemonCandies();
}
/**
* Helper function to load Pokemon from a save file into the player's inventory for this
* Pokemon Species
*/
public void loadPokemon(Pokemon pokemon) {
caughtPokemon.add(pokemon);
}
/**
* Find a Pokemon of the given combatPower in the player's inventory for this species.
*
*/
public Pokemon findPokemon(int cp) throws PokedexException {
for(int i = 0; i < caughtPokemon.size(); i++){
Pokemon mon = caughtPokemon.get(i);
if(mon.getCombatPower() == cp){
return mon;
}
}
throw new PokedexException(Config.POKEMON_NOT_FOUND);
}
/**
* Transfer a Pokemon with the provided combatPower from the player's inventory
* to the Professor. This removes the Pokemon from the player's inventory and
* also increases the number of candies the player has associated with this
* PokemonSpecies.
*/
public Pokemon transferPokemon(int cp) throws PokedexException {
for(int i = 0; i < caughtPokemon.size(); i++){
if(caughtPokemon.get(i).getCombatPower() == cp){
Pokemon mon = caughtPokemon.remove(i);
this.addTransferCandies();
return mon;
}
}
throw new PokedexException(Config.POKEMON_NOT_FOUND);
}
/**
* Check if the player has any Pokemon of this species
*/
public boolean isEmpty() {
return caughtPokemon.isEmpty();
}
/**
* Increment candies when a new pokemon is caught
*/
private void addNewPokemonCandies() {
this.candies += PokemonGO.NEW_POKEMON_CANDIES;
}
/**
* Increment candies when a pokemon is transferred to the professor
*/
private void addTransferCandies() {
this.candies += PokemonGO.TRANSFER_POKEMON_CANDIES;
}
/**
* Prepare a listing of all the Pokemon of this species that are currently in the
* player's inventory.
*
*/
public String caughtPokemonToString() {
String pokemonStr = "";
for(int i = 0; i < caughtPokemon.size(); i++){
pokemonStr += Integer.toString(caughtPokemon.get(i).getCombatPower())+" ";
}
return pokemonStr;
}
/**
* Prepare a String representing this entire PokemonSpecies. This is used to
* save the PokemonSpecies (one part of the Pokedex) to a file to
* save the player's game.
*
*/
public String toString() {
String speciesStr = Integer.toString(pokedexNumber)
+" "+speciesName
+" "+Integer.toString(candies)
+" "+this.caughtPokemonToString()
+" ";
return speciesStr;
}
}
Solution
import java.util.ArrayList;
//import java.util.Iterator;
/**
* A PokemonSpecies entry in the Pokedex. Maintains the number of candies associated
* with the Pokemon species as well as the Trainer's inventory of Pokemon of this
* species.
*/
public class PokemonSpecies {
private int pokedexNumber;
private String speciesName;
private int candies;
/**
* Maintains the list of Pokemon of this species in the Trainer's inventory.
*/
private ArrayList caughtPokemon;
/**
* Constructor suitable for a newly encountered Pokemon species during the course of the
* game and for loading species data from a save file.
*
*/
public PokemonSpecies(int pokedexNumber, String speciesName, int candies) {
this.pokedexNumber = pokedexNumber;
this.speciesName = speciesName;
this.candies = candies;
// construct caughtPokemon
caughtPokemon = new ArrayList();
}
/**
* Getter methods
*/
public Integer getPokedexNumber() {
return pokedexNumber;
}
public String getSpeciesName() {
return speciesName;
}
public int getCandies() {
return candies;
}
/**
* Add a newly caught Pokemon to the player's inventory and
* increase the number of candies for this PokemonSpecies
*
* @param pokemon the newly caught Pokemon
*/
public void addNewPokemon(Pokemon pokemon) {
caughtPokemon.add(pokemon);
this.addNewPokemonCandies();
}
/**
* Helper function to load Pokemon from a save file into the player's inventory for this
* Pokemon Species
*/
public void loadPokemon(Pokemon pokemon) {
caughtPokemon.add(pokemon);
}
/**
* Find a Pokemon of the given combatPower in the player's inventory for this species.
*
*/
public Pokemon findPokemon(int cp) throws PokedexException {
for(int i = 0; i < caughtPokemon.size(); i++){
Pokemon mon = caughtPokemon.get(i);
if(mon.getCombatPower() == cp){
return mon;
}
}
throw new PokedexException(Config.POKEMON_NOT_FOUND);
}
/**
* Transfer a Pokemon with the provided combatPower from the player's inventory
* to the Professor. This removes the Pokemon from the player's inventory and
* also increases the number of candies the player has associated with this
* PokemonSpecies.
*/
public Pokemon transferPokemon(int cp) throws PokedexException {
for(int i = 0; i < caughtPokemon.size(); i++){
if(caughtPokemon.get(i).getCombatPower() == cp){
Pokemon mon = caughtPokemon.remove(i);
this.addTransferCandies();
return mon;
}
}
throw new PokedexException(Config.POKEMON_NOT_FOUND);
}
/**
* Check if the player has any Pokemon of this species
*/
public boolean isEmpty() {
return caughtPokemon.isEmpty();
}
/**
* Increment candies when a new pokemon is caught
*/
private void addNewPokemonCandies() {
this.candies += PokemonGO.NEW_POKEMON_CANDIES;
}
/**
* Increment candies when a pokemon is transferred to the professor
*/
private void addTransferCandies() {
this.candies += PokemonGO.TRANSFER_POKEMON_CANDIES;
}
/**
* Prepare a listing of all the Pokemon of this species that are currently in the
* player's inventory.
*
*/
public String caughtPokemonToString() {
String pokemonStr = "";
for(int i = 0; i < caughtPokemon.size(); i++){
pokemonStr += Integer.toString(caughtPokemon.get(i).getCombatPower())+" ";
}
return pokemonStr;
}
/**
* Prepare a String representing this entire PokemonSpecies. This is used to
* save the PokemonSpecies (one part of the Pokedex) to a file to
* save the player's game.
*
*/
public String toString() {
String speciesStr = Integer.toString(pokedexNumber)
+" "+speciesName
+" "+Integer.toString(candies)
+" "+this.caughtPokemonToString()
+" ";
return speciesStr;
}
}

More Related Content

More from dilipanushkagallery

Please rateAnswer The accuracy was poor, but the precision was go.pdf
Please rateAnswer The accuracy was poor, but the precision was go.pdfPlease rateAnswer The accuracy was poor, but the precision was go.pdf
Please rateAnswer The accuracy was poor, but the precision was go.pdf
dilipanushkagallery
 
resultreceptoreffectorPATELLAR REFLEXa stretch reflexGolgi.pdf
resultreceptoreffectorPATELLAR REFLEXa stretch reflexGolgi.pdfresultreceptoreffectorPATELLAR REFLEXa stretch reflexGolgi.pdf
resultreceptoreffectorPATELLAR REFLEXa stretch reflexGolgi.pdf
dilipanushkagallery
 
Please find the answers and explanations belowPart 1Critical l.pdf
Please find the answers and explanations belowPart 1Critical l.pdfPlease find the answers and explanations belowPart 1Critical l.pdf
Please find the answers and explanations belowPart 1Critical l.pdf
dilipanushkagallery
 
Psychoanalysis is a method of treating mental disorders, shaped by p.pdf
Psychoanalysis is a method of treating mental disorders, shaped by p.pdfPsychoanalysis is a method of treating mental disorders, shaped by p.pdf
Psychoanalysis is a method of treating mental disorders, shaped by p.pdf
dilipanushkagallery
 
pH+pOH=14 pH=14-pOH=14-11.97=2.03SolutionpH+pOH=14 pH=14-p.pdf
pH+pOH=14 pH=14-pOH=14-11.97=2.03SolutionpH+pOH=14 pH=14-p.pdfpH+pOH=14 pH=14-pOH=14-11.97=2.03SolutionpH+pOH=14 pH=14-p.pdf
pH+pOH=14 pH=14-pOH=14-11.97=2.03SolutionpH+pOH=14 pH=14-p.pdf
dilipanushkagallery
 
No solutionSolutionNo solution.pdf
No solutionSolutionNo solution.pdfNo solutionSolutionNo solution.pdf
No solutionSolutionNo solution.pdf
dilipanushkagallery
 
The concentration of the reactants decreases .pdf
                     The concentration of the reactants decreases     .pdf                     The concentration of the reactants decreases     .pdf
The concentration of the reactants decreases .pdf
dilipanushkagallery
 
let E0 be given, a belongs to X= d(f(x),f(a)) = Ld(x,a)=.pdf
let E0 be given, a belongs to X= d(f(x),f(a)) = Ld(x,a)=.pdflet E0 be given, a belongs to X= d(f(x),f(a)) = Ld(x,a)=.pdf
let E0 be given, a belongs to X= d(f(x),f(a)) = Ld(x,a)=.pdf
dilipanushkagallery
 
Insufficient data. Figure missing.SolutionInsufficient data. F.pdf
Insufficient data. Figure missing.SolutionInsufficient data. F.pdfInsufficient data. Figure missing.SolutionInsufficient data. F.pdf
Insufficient data. Figure missing.SolutionInsufficient data. F.pdf
dilipanushkagallery
 
Hershay and Chase designed an experiment to determine which molecule.pdf
Hershay and Chase designed an experiment to determine which molecule.pdfHershay and Chase designed an experiment to determine which molecule.pdf
Hershay and Chase designed an experiment to determine which molecule.pdf
dilipanushkagallery
 
Humans being a diploid organism inherit two copies of each gene, fro.pdf
Humans being a diploid organism inherit two copies of each gene, fro.pdfHumans being a diploid organism inherit two copies of each gene, fro.pdf
Humans being a diploid organism inherit two copies of each gene, fro.pdf
dilipanushkagallery
 
Given, pH of buffer = 8.86                [H+] = 1.380 10-9 M .pdf
Given, pH of buffer = 8.86                [H+] = 1.380  10-9 M .pdfGiven, pH of buffer = 8.86                [H+] = 1.380  10-9 M .pdf
Given, pH of buffer = 8.86                [H+] = 1.380 10-9 M .pdf
dilipanushkagallery
 
exists. ThenSolutionexists. Then.pdf
exists. ThenSolutionexists. Then.pdfexists. ThenSolutionexists. Then.pdf
exists. ThenSolutionexists. Then.pdf
dilipanushkagallery
 
D. A mount point is the connection point to the folder on a logical .pdf
D. A mount point is the connection point to the folder on a logical .pdfD. A mount point is the connection point to the folder on a logical .pdf
D. A mount point is the connection point to the folder on a logical .pdf
dilipanushkagallery
 
Both Sfe = n and Sfe = SfoSolutionBoth Sfe = n and Sfe = Sfo.pdf
Both Sfe = n and Sfe = SfoSolutionBoth Sfe = n and Sfe = Sfo.pdfBoth Sfe = n and Sfe = SfoSolutionBoth Sfe = n and Sfe = Sfo.pdf
Both Sfe = n and Sfe = SfoSolutionBoth Sfe = n and Sfe = Sfo.pdf
dilipanushkagallery
 
Answer7).DNA is the long chains of nucleotides. Chromosomes and.pdf
Answer7).DNA is the long chains of nucleotides. Chromosomes and.pdfAnswer7).DNA is the long chains of nucleotides. Chromosomes and.pdf
Answer7).DNA is the long chains of nucleotides. Chromosomes and.pdf
dilipanushkagallery
 
Any function consisting of one or more terms of variables with whole.pdf
Any function consisting of one or more terms of variables with whole.pdfAny function consisting of one or more terms of variables with whole.pdf
Any function consisting of one or more terms of variables with whole.pdf
dilipanushkagallery
 
An expense must possess some defined characteristics which classifie.pdf
An expense must possess some defined characteristics which classifie.pdfAn expense must possess some defined characteristics which classifie.pdf
An expense must possess some defined characteristics which classifie.pdf
dilipanushkagallery
 
Ans 1.During telophase, the following events happenSolution.pdf
Ans 1.During telophase, the following events happenSolution.pdfAns 1.During telophase, the following events happenSolution.pdf
Ans 1.During telophase, the following events happenSolution.pdf
dilipanushkagallery
 
Alterative Hypothesis H1 p 0.30SolutionAlterative Hypothesi.pdf
Alterative Hypothesis H1 p  0.30SolutionAlterative Hypothesi.pdfAlterative Hypothesis H1 p  0.30SolutionAlterative Hypothesi.pdf
Alterative Hypothesis H1 p 0.30SolutionAlterative Hypothesi.pdf
dilipanushkagallery
 

More from dilipanushkagallery (20)

Please rateAnswer The accuracy was poor, but the precision was go.pdf
Please rateAnswer The accuracy was poor, but the precision was go.pdfPlease rateAnswer The accuracy was poor, but the precision was go.pdf
Please rateAnswer The accuracy was poor, but the precision was go.pdf
 
resultreceptoreffectorPATELLAR REFLEXa stretch reflexGolgi.pdf
resultreceptoreffectorPATELLAR REFLEXa stretch reflexGolgi.pdfresultreceptoreffectorPATELLAR REFLEXa stretch reflexGolgi.pdf
resultreceptoreffectorPATELLAR REFLEXa stretch reflexGolgi.pdf
 
Please find the answers and explanations belowPart 1Critical l.pdf
Please find the answers and explanations belowPart 1Critical l.pdfPlease find the answers and explanations belowPart 1Critical l.pdf
Please find the answers and explanations belowPart 1Critical l.pdf
 
Psychoanalysis is a method of treating mental disorders, shaped by p.pdf
Psychoanalysis is a method of treating mental disorders, shaped by p.pdfPsychoanalysis is a method of treating mental disorders, shaped by p.pdf
Psychoanalysis is a method of treating mental disorders, shaped by p.pdf
 
pH+pOH=14 pH=14-pOH=14-11.97=2.03SolutionpH+pOH=14 pH=14-p.pdf
pH+pOH=14 pH=14-pOH=14-11.97=2.03SolutionpH+pOH=14 pH=14-p.pdfpH+pOH=14 pH=14-pOH=14-11.97=2.03SolutionpH+pOH=14 pH=14-p.pdf
pH+pOH=14 pH=14-pOH=14-11.97=2.03SolutionpH+pOH=14 pH=14-p.pdf
 
No solutionSolutionNo solution.pdf
No solutionSolutionNo solution.pdfNo solutionSolutionNo solution.pdf
No solutionSolutionNo solution.pdf
 
The concentration of the reactants decreases .pdf
                     The concentration of the reactants decreases     .pdf                     The concentration of the reactants decreases     .pdf
The concentration of the reactants decreases .pdf
 
let E0 be given, a belongs to X= d(f(x),f(a)) = Ld(x,a)=.pdf
let E0 be given, a belongs to X= d(f(x),f(a)) = Ld(x,a)=.pdflet E0 be given, a belongs to X= d(f(x),f(a)) = Ld(x,a)=.pdf
let E0 be given, a belongs to X= d(f(x),f(a)) = Ld(x,a)=.pdf
 
Insufficient data. Figure missing.SolutionInsufficient data. F.pdf
Insufficient data. Figure missing.SolutionInsufficient data. F.pdfInsufficient data. Figure missing.SolutionInsufficient data. F.pdf
Insufficient data. Figure missing.SolutionInsufficient data. F.pdf
 
Hershay and Chase designed an experiment to determine which molecule.pdf
Hershay and Chase designed an experiment to determine which molecule.pdfHershay and Chase designed an experiment to determine which molecule.pdf
Hershay and Chase designed an experiment to determine which molecule.pdf
 
Humans being a diploid organism inherit two copies of each gene, fro.pdf
Humans being a diploid organism inherit two copies of each gene, fro.pdfHumans being a diploid organism inherit two copies of each gene, fro.pdf
Humans being a diploid organism inherit two copies of each gene, fro.pdf
 
Given, pH of buffer = 8.86                [H+] = 1.380 10-9 M .pdf
Given, pH of buffer = 8.86                [H+] = 1.380  10-9 M .pdfGiven, pH of buffer = 8.86                [H+] = 1.380  10-9 M .pdf
Given, pH of buffer = 8.86                [H+] = 1.380 10-9 M .pdf
 
exists. ThenSolutionexists. Then.pdf
exists. ThenSolutionexists. Then.pdfexists. ThenSolutionexists. Then.pdf
exists. ThenSolutionexists. Then.pdf
 
D. A mount point is the connection point to the folder on a logical .pdf
D. A mount point is the connection point to the folder on a logical .pdfD. A mount point is the connection point to the folder on a logical .pdf
D. A mount point is the connection point to the folder on a logical .pdf
 
Both Sfe = n and Sfe = SfoSolutionBoth Sfe = n and Sfe = Sfo.pdf
Both Sfe = n and Sfe = SfoSolutionBoth Sfe = n and Sfe = Sfo.pdfBoth Sfe = n and Sfe = SfoSolutionBoth Sfe = n and Sfe = Sfo.pdf
Both Sfe = n and Sfe = SfoSolutionBoth Sfe = n and Sfe = Sfo.pdf
 
Answer7).DNA is the long chains of nucleotides. Chromosomes and.pdf
Answer7).DNA is the long chains of nucleotides. Chromosomes and.pdfAnswer7).DNA is the long chains of nucleotides. Chromosomes and.pdf
Answer7).DNA is the long chains of nucleotides. Chromosomes and.pdf
 
Any function consisting of one or more terms of variables with whole.pdf
Any function consisting of one or more terms of variables with whole.pdfAny function consisting of one or more terms of variables with whole.pdf
Any function consisting of one or more terms of variables with whole.pdf
 
An expense must possess some defined characteristics which classifie.pdf
An expense must possess some defined characteristics which classifie.pdfAn expense must possess some defined characteristics which classifie.pdf
An expense must possess some defined characteristics which classifie.pdf
 
Ans 1.During telophase, the following events happenSolution.pdf
Ans 1.During telophase, the following events happenSolution.pdfAns 1.During telophase, the following events happenSolution.pdf
Ans 1.During telophase, the following events happenSolution.pdf
 
Alterative Hypothesis H1 p 0.30SolutionAlterative Hypothesi.pdf
Alterative Hypothesis H1 p  0.30SolutionAlterative Hypothesi.pdfAlterative Hypothesis H1 p  0.30SolutionAlterative Hypothesi.pdf
Alterative Hypothesis H1 p 0.30SolutionAlterative Hypothesi.pdf
 

Recently uploaded

BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Leena Ghag-Sakpal
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdfIGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
Amin Marwan
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
B. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdfB. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdf
BoudhayanBhattachari
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
MysoreMuleSoftMeetup
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
imrankhan141184
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 

Recently uploaded (20)

BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdfIGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
B. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdfB. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdf
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 

import java.util.ArrayList; import java.util.Iterator; .pdf

  • 1. import java.util.ArrayList; //import java.util.Iterator; /** * A PokemonSpecies entry in the Pokedex. Maintains the number of candies associated * with the Pokemon species as well as the Trainer's inventory of Pokemon of this * species. */ public class PokemonSpecies { private int pokedexNumber; private String speciesName; private int candies; /** * Maintains the list of Pokemon of this species in the Trainer's inventory. */ private ArrayList caughtPokemon; /** * Constructor suitable for a newly encountered Pokemon species during the course of the * game and for loading species data from a save file. * */ public PokemonSpecies(int pokedexNumber, String speciesName, int candies) { this.pokedexNumber = pokedexNumber; this.speciesName = speciesName; this.candies = candies; // construct caughtPokemon caughtPokemon = new ArrayList(); } /** * Getter methods */ public Integer getPokedexNumber() { return pokedexNumber; } public String getSpeciesName() {
  • 2. return speciesName; } public int getCandies() { return candies; } /** * Add a newly caught Pokemon to the player's inventory and * increase the number of candies for this PokemonSpecies * * @param pokemon the newly caught Pokemon */ public void addNewPokemon(Pokemon pokemon) { caughtPokemon.add(pokemon); this.addNewPokemonCandies(); } /** * Helper function to load Pokemon from a save file into the player's inventory for this * Pokemon Species */ public void loadPokemon(Pokemon pokemon) { caughtPokemon.add(pokemon); } /** * Find a Pokemon of the given combatPower in the player's inventory for this species. * */ public Pokemon findPokemon(int cp) throws PokedexException { for(int i = 0; i < caughtPokemon.size(); i++){ Pokemon mon = caughtPokemon.get(i); if(mon.getCombatPower() == cp){ return mon; } } throw new PokedexException(Config.POKEMON_NOT_FOUND); } /**
  • 3. * Transfer a Pokemon with the provided combatPower from the player's inventory * to the Professor. This removes the Pokemon from the player's inventory and * also increases the number of candies the player has associated with this * PokemonSpecies. */ public Pokemon transferPokemon(int cp) throws PokedexException { for(int i = 0; i < caughtPokemon.size(); i++){ if(caughtPokemon.get(i).getCombatPower() == cp){ Pokemon mon = caughtPokemon.remove(i); this.addTransferCandies(); return mon; } } throw new PokedexException(Config.POKEMON_NOT_FOUND); } /** * Check if the player has any Pokemon of this species */ public boolean isEmpty() { return caughtPokemon.isEmpty(); } /** * Increment candies when a new pokemon is caught */ private void addNewPokemonCandies() { this.candies += PokemonGO.NEW_POKEMON_CANDIES; } /** * Increment candies when a pokemon is transferred to the professor */ private void addTransferCandies() { this.candies += PokemonGO.TRANSFER_POKEMON_CANDIES; }
  • 4. /** * Prepare a listing of all the Pokemon of this species that are currently in the * player's inventory. * */ public String caughtPokemonToString() { String pokemonStr = ""; for(int i = 0; i < caughtPokemon.size(); i++){ pokemonStr += Integer.toString(caughtPokemon.get(i).getCombatPower())+" "; } return pokemonStr; } /** * Prepare a String representing this entire PokemonSpecies. This is used to * save the PokemonSpecies (one part of the Pokedex) to a file to * save the player's game. * */ public String toString() { String speciesStr = Integer.toString(pokedexNumber) +" "+speciesName +" "+Integer.toString(candies) +" "+this.caughtPokemonToString() +" "; return speciesStr; } } Solution import java.util.ArrayList; //import java.util.Iterator; /** * A PokemonSpecies entry in the Pokedex. Maintains the number of candies associated * with the Pokemon species as well as the Trainer's inventory of Pokemon of this
  • 5. * species. */ public class PokemonSpecies { private int pokedexNumber; private String speciesName; private int candies; /** * Maintains the list of Pokemon of this species in the Trainer's inventory. */ private ArrayList caughtPokemon; /** * Constructor suitable for a newly encountered Pokemon species during the course of the * game and for loading species data from a save file. * */ public PokemonSpecies(int pokedexNumber, String speciesName, int candies) { this.pokedexNumber = pokedexNumber; this.speciesName = speciesName; this.candies = candies; // construct caughtPokemon caughtPokemon = new ArrayList(); } /** * Getter methods */ public Integer getPokedexNumber() { return pokedexNumber; } public String getSpeciesName() { return speciesName; } public int getCandies() { return candies; } /**
  • 6. * Add a newly caught Pokemon to the player's inventory and * increase the number of candies for this PokemonSpecies * * @param pokemon the newly caught Pokemon */ public void addNewPokemon(Pokemon pokemon) { caughtPokemon.add(pokemon); this.addNewPokemonCandies(); } /** * Helper function to load Pokemon from a save file into the player's inventory for this * Pokemon Species */ public void loadPokemon(Pokemon pokemon) { caughtPokemon.add(pokemon); } /** * Find a Pokemon of the given combatPower in the player's inventory for this species. * */ public Pokemon findPokemon(int cp) throws PokedexException { for(int i = 0; i < caughtPokemon.size(); i++){ Pokemon mon = caughtPokemon.get(i); if(mon.getCombatPower() == cp){ return mon; } } throw new PokedexException(Config.POKEMON_NOT_FOUND); } /** * Transfer a Pokemon with the provided combatPower from the player's inventory * to the Professor. This removes the Pokemon from the player's inventory and * also increases the number of candies the player has associated with this * PokemonSpecies. */ public Pokemon transferPokemon(int cp) throws PokedexException {
  • 7. for(int i = 0; i < caughtPokemon.size(); i++){ if(caughtPokemon.get(i).getCombatPower() == cp){ Pokemon mon = caughtPokemon.remove(i); this.addTransferCandies(); return mon; } } throw new PokedexException(Config.POKEMON_NOT_FOUND); } /** * Check if the player has any Pokemon of this species */ public boolean isEmpty() { return caughtPokemon.isEmpty(); } /** * Increment candies when a new pokemon is caught */ private void addNewPokemonCandies() { this.candies += PokemonGO.NEW_POKEMON_CANDIES; } /** * Increment candies when a pokemon is transferred to the professor */ private void addTransferCandies() { this.candies += PokemonGO.TRANSFER_POKEMON_CANDIES; } /** * Prepare a listing of all the Pokemon of this species that are currently in the * player's inventory. * */ public String caughtPokemonToString() {
  • 8. String pokemonStr = ""; for(int i = 0; i < caughtPokemon.size(); i++){ pokemonStr += Integer.toString(caughtPokemon.get(i).getCombatPower())+" "; } return pokemonStr; } /** * Prepare a String representing this entire PokemonSpecies. This is used to * save the PokemonSpecies (one part of the Pokedex) to a file to * save the player's game. * */ public String toString() { String speciesStr = Integer.toString(pokedexNumber) +" "+speciesName +" "+Integer.toString(candies) +" "+this.caughtPokemonToString() +" "; return speciesStr; } }