The Resident class maintains, for a set of addresses, the set of residents living at each address. Do not worry about the import statements. Implement a constructor for Resident that creates an empty map of addresses to a set of resident names, given an instance field named map as declared below.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question

java

The **Resident** class maintains, for a set of addresses, the set of residents living at each address. Do not worry about the import statements.

Implement a constructor for Resident that creates an empty map of addresses to a set of resident names, given an instance field named map as declared below.

```java
public class Resident {
    Map<String, Set<String>> map;

    public Resident() {
        // YOU MUST IMPLEMENT THIS METHOD
    }
    public void addResident(String address, String residentName) {
    }
    public void displayResidentsPerAddress() {
    }
}
```

In this class:
- A map is used to associate each address (a String) with a set of resident names (a Set of Strings).
- The constructor `Resident()` needs implementation to initialize this map.
- The `addResident` method is intended to add a resident's name to a specific address.
- The `displayResidentsPerAddress` method is designed to display the residents living at each address.
Transcribed Image Text:The **Resident** class maintains, for a set of addresses, the set of residents living at each address. Do not worry about the import statements. Implement a constructor for Resident that creates an empty map of addresses to a set of resident names, given an instance field named map as declared below. ```java public class Resident { Map<String, Set<String>> map; public Resident() { // YOU MUST IMPLEMENT THIS METHOD } public void addResident(String address, String residentName) { } public void displayResidentsPerAddress() { } } ``` In this class: - A map is used to associate each address (a String) with a set of resident names (a Set of Strings). - The constructor `Resident()` needs implementation to initialize this map. - The `addResident` method is intended to add a resident's name to a specific address. - The `displayResidentsPerAddress` method is designed to display the residents living at each address.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr