Methods in SocialNetwork
Learn how to extend your SocialNetwork class with additional methods.
In our last lesson, we built a SocialNetwork
class that simply stored Users
and Posts
. Now, let’s take our design further by giving SocialNetwork
the ability to manage these objects.
Imagine a bustling city where thousands of people live and interact. Without a mayor or city planner, chaos would reign! Similarly, our SocialNetwork
class isn’t just a passive container—it’s the mayor of Chirpy, actively managing users and posts to keep the platform organized.
You’re tasked with designing the SocialNetwork
class for Chirpy, which must empower the platform with the following features:
Search for users: Allow the system to locate a user by their username.
Ensure unique usernames: Prevent duplicate usernames from being added.
Remove users: Enable the removal of a user from the network. ...