1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
k0ka [10]
4 years ago
10

Imagine you're developing a Pokemon game, and you need to implement the battle party mechanic. Recall that the player's party ca

n 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 Write a program, test using stdin → stdout

Computers and Technology
1 answer:
valina [46]4 years ago
4 0

Answer:

Complete code is given below and output is also attached.

Explanation:

import java.util.ArrayList;

import java.util.HashMap;

import java.util.Iterator;

import java.util.Map;

import java.util.Set;

public class Test {

  public static void main(String[] args) {

      String [] names = {"Pikachu", "Venuasur", "Charizard", "Blastoise", "Lapras", "Sonarlax"};

      int[] levels = {88, 84, 84, 84, 80, 82};

     

      ArrayList<HashMap<String, Integer>> party = createParty(names, levels);

     

      //looping through the list

      for(HashMap<String, Integer> i: party) {

         

          Set set = i.entrySet();

          Iterator itr = set.iterator();

          //showing output

          while(itr.hasNext()) {

              Map.Entry mentry = (Map.Entry)itr.next();

              System.out.println(mentry.getKey()+" "+mentry.getValue());

          }

      }

  }

  private static ArrayList<HashMap<String, Integer>> createParty(String[] names, int[] levels) {

      ArrayList<HashMap<String, Integer>> party = new ArrayList<>();

     

      for(int i=0; i<names.length; i++) {

          //creating new hashmap

          HashMap<String, Integer> pokemon = new HashMap<>();

          pokemon.put(names[i], levels[i]);//adding pokemon

          party.add(pokemon);//adding it to the list

      }

     

      return party;

  }

}

You might be interested in
Which command is used to copy entire folder structures between volumes or across a network while maintaining all NTFS file permi
True [87]

Answer:

Robocopy

Explanation:

The newer and most used command to accomplish this is Robocopy. This code does exactly what is described in the question, it copies the entire structure of the volume in question but still maintains all of its permissions and attributes. It also allows you to copy large datasets at an extremely fast speed, roughly 150 MB/sec. Robocopy can even resume interrupted file transfers without loss of data.

8 0
3 years ago
How are some businesses capitalizing on social media at the time of someones death
stiv31 [10]
They'll post condolences messages etc which means many people will discover their business if they are looking for posts mentioning the deceased's name on social media. 
7 0
4 years ago
What will be the output of “AAAAMMMMMHHHVV” using a file compression technique?
stiks02 [169]

I think AAAAMMMMMHHVVV

i think suppose to be 3 v's

3 0
3 years ago
Read 2 more answers
Identify the output, input, and any missing information for the following problem. George wants to find out how much extra he wi
rosijanka [135]

Answer:

The answer is $1600

Explanation:

Identify the output, input, and any missing information for the following problem. George wants to find out how much extra he will get paid next month. George gets paid $10 an hour and words 40 hour work weeks.

Usually, a month contains 4 weeks.

The formula we would use is : rate * hours per week * total weeks in a month.

The result would be 10x40x4 = $1600

3 0
3 years ago
What is a form of programming where multiple tasks can be carried out at the same time?
Tanzania [10]
Hi!

This form of programming may be known as multiprogramming or multithreaded programming.

Try to think of a thread as basically one structured process which is occurring. Having a multithreaded programming means you are doing multiple processes at once.

While this is <em />an <em>extremely </em>simplified explaniation, it's a decent way to think about it on a basic level.

Hopefully, this helps! =)
5 0
3 years ago
Other questions:
  • Select the correct answer.
    8·1 answer
  • Which remote access configuration option should you choose if you want mobile users to be able to make a secure connection to th
    9·2 answers
  • When using a search engine, what is the name of a word or phrase somebody types to find something online?
    12·2 answers
  • Give an example of a class and an example of an object. Describe what a class is, what an object is, and how they are related. U
    6·1 answer
  • A_____ handles all the instructions that it received from hardware and software which are available on the computer ​
    10·1 answer
  • Pls help me!! I will give 35 points and mark brainliest !!!
    10·1 answer
  • How do you give brainlest things out?
    14·2 answers
  • Need help asap
    5·1 answer
  • Write a program that randomly (using the random number generator) picks gift card winners from a list of customers (every custom
    14·1 answer
  • Which company provides a crowdsourcing platform for corporate research and development?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!