Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Challenge: Store and Retrieve User Scores | Section
Practice
Projects
Quizzes & Challenges
Questionários
Challenges
/
Fundamental Data Structures in Java

bookChallenge: Store and Retrieve User Scores

Tarefa

Swipe to start coding

In this task, you need to complete the UserScores class by filling in the missing parts. The goal is to manage a collection of users and their scores using a HashMap. You will implement adding a user, retrieving a user’s score, removing a user, and printing all users with their scores.

  1. In the addUser(String name, int score) method:

    • Add the name and score pair to the userMap.
  2. In the getUserScore(String name) method:

    • Return the score associated with the given name.
  3. In the removeUser(String name) method:

    • Remove the entry for the given name from the userMap.
  4. In the printAllUsers() method:

    • For each entry in userMap.entrySet(), get the key (user name) and value (score).

Solução

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 15
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

close

bookChallenge: Store and Retrieve User Scores

Deslize para mostrar o menu

Tarefa

Swipe to start coding

In this task, you need to complete the UserScores class by filling in the missing parts. The goal is to manage a collection of users and their scores using a HashMap. You will implement adding a user, retrieving a user’s score, removing a user, and printing all users with their scores.

  1. In the addUser(String name, int score) method:

    • Add the name and score pair to the userMap.
  2. In the getUserScore(String name) method:

    • Return the score associated with the given name.
  3. In the removeUser(String name) method:

    • Remove the entry for the given name from the userMap.
  4. In the printAllUsers() method:

    • For each entry in userMap.entrySet(), get the key (user name) and value (score).

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 15
single

single

some-alt