Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Challenge: Store and Retrieve User Scores | Section
Fundamental Data Structures in Java

bookChallenge: Store and Retrieve User Scores

Aufgabe

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

Lösung

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 15
single

single

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

close

bookChallenge: Store and Retrieve User Scores

Swipe um das Menü anzuzeigen

Aufgabe

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

Lösung

Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 15
single

single

some-alt