Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Imagine you're developing a Pokemon game, and you need to implement the battle party mechanic. Recall that the player's party can hold at most 6

Imagine you're developing a Pokemon game, and you need to implement the battle party mechanic. Recall that the player's party can hold at most 6 Pokemon. To simplify things, you want to implement it as an ArrayList containing 6 elements (1 for each Pokemon in the party), and to simplify things even further, you decide to avoid making a custom Pokemon class. Instead, you choose to represent each Pokemon as a HashMap containing two keys: "Name" and "Level". The value associated with the key "Name" will be a String denoting the Pokemon's name, and the value associated with the key "Level" will be an Integer denoting the Pokemon's level.

TASK: Write a public static method called createParty that has one parameter of type String[] called names containing the Pokemon names, followed by a parameter of type int[] called levels containing the Pokemon levels (where names[i] and levels[i] are the name and level of Pokemon i in the party). It should return the party as a ArrayList> as described above

HINT: Each Pokemon would be its own HashMap, and each of these HashMaps has exactly two keys, both of which are Strings: "Name" and "Level"

Sample Input:

Pikachu Venusaur Charizard Blastoise Lapras Snorlax 88 84 84 84 80 82

Sample Output:

Pikachu 88 Venusaur 84 Charizard 84 Blastoise 84 Lapras 80 Snorlax 82

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

Step: 3

blur-text-image

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

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

Students also viewed these Databases questions