Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Challenge: Store and Retrieve User Scores | Section
Practice
Projects
Quizzes & Challenges
Вікторини
Challenges
/
Fundamental Data Structures in Java

bookChallenge: Store and Retrieve User Scores

Завдання

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).

Рішення

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 15
single

single

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

close

bookChallenge: Store and Retrieve User Scores

Свайпніть щоб показати меню

Завдання

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).

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 15
single

single

some-alt