Question: Part 5: Backpack.java and Pokedex.java (Implementing and testing) (Pair programming allowed) (1.5 point) Implement Backpack.java This class has one private member variables: ArrayList myItems :
Part 5: Backpack.java and Pokedex.java (Implementing and testing) (Pair programming allowed) (1.5 point)
Implement Backpack.java
This class has one private member variables:
- ArrayList
- myItems
: List of items to store pokeballs and berries.
This class should contain the following public methods. You must name your methods exactly as specified below:
One constructors:
public Backpack ()
This constructor should initialize a resizable-array ArrayLists which is the member variables of this Backpack class.
Other methods:
public void add(Item item)
This method takes a Item object and adds it to myItems ArrayList
public void display()
This method prints out all the items in the backpack. Start printing out whats in myItems ArrayList by stating Items in the backpack:. Make use of the toString() method implemented in previous parts. If myItems is empty, print None.
Implement Pokedex.java
This class has one private member variables:
- ArrayList
myPokedex : List of Pokemons to store wild pokemons and pal pokemons.
This class should contain the following public methods. You must name your methods exactly as specified below:
One constructors:
public Pokedex ()
This constructor should initialize a resizable-array ArrayLists which is the member variables of this Pokedex class.
Other methods:
public void add(Pokemon pokemon)
This method takes a pokemon object and adds it to myPokedex ArrayList
public void display()
This method prints out all the Pokemons in the pokedex. Start printing out whats in myPokedex ArrayList by stating Pokemons in the pokedex:. Make use of the toString() method implemented in previous parts. If myPokedex is empty, print None.
Test Backpack.java and Pokedex.java in PA8Tester.java
- Display the empty backpack by calling display() method
- Add 2 pokeballs that were created in part 1 to the backpack and display the backpack
- Add 2 berries that were created in part 2 to the backpack and display the backpack
- Display the empty pokedex by calling display() method
- Add 2 pal pokemons that were created in part 3 to the pokedex and display the pokedex
- Add 2 wild pokemons that were created in part 3 to the pokedex and display the pokedex
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
