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

bookChallenge: Store and Retrieve User Scores

Tehtävä

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

Ratkaisu

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 15
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

close

bookChallenge: Store and Retrieve User Scores

Pyyhkäise näyttääksesi valikon

Tehtävä

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

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 15
single

single

some-alt