Create a class FacebookLikeManager with three public methods. The purpose of this class is to ingest this users.txt file and process it as to later provide information about those users.  users.txt   Mike: Kristen, Sara, Nate, Anthony, Randy     Kristen: Mike, John, Steve, Bill   Bill: Sara, Nate   Sara: Nate, Anthony A line in the file will look something like this:  Mike: Steve, John, Tony This line represents that the users Steve, John, and Tony have liked the user Mike.   The three public methods will be:       a  public List getAllUsers() This will return a unique list of all users that appeared in the file. Note: All names in the file are users. Even if a user only appears when liking someone, they will be present in the List returned by getAllUsers.         b  public List getLikes(String user) This will take a String representing a user (like “Mike”) and return a unique List containing all of the users that have liked the user “Mike.”        c   public List getLikedBy(String user) This will take a String representing a user (like “Tony”) and return a unique List containing each user that “Tony” has liked. create a Main to test your work.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Create a class FacebookLikeManager with three public methods.

The purpose of this class is to ingest this users.txt file and process it as to later provide information about those users. 

users.txt

 

Mike: Kristen, Sara, Nate, Anthony, Randy

 
 

Kristen: Mike, John, Steve, Bill

 

Bill: Sara, Nate

 

Sara: Nate, Anthony



A line in the file will look something like this: 

Mike: Steve, John, Tony

This line represents that the users Steve, John, and Tony have liked the user Mike. 

 The three public methods will be:

      a  public List<String> getAllUsers()

This will return a unique list of all users that appeared in the file. Note: All names in the file are users. Even if a user only appears when liking someone, they will be present in the List returned by getAllUsers.

        b  public List<String> getLikes(String user)

This will take a String representing a user (like “Mike”) and return a unique List containing all of the users that have liked the user “Mike.”

       c   public List<String> getLikedBy(String user)

This will take a String representing a user (like “Tony”) and return a unique List containing each user that “Tony” has liked.

create a Main to test your work.

Expert Solution
Step 1

Here our task is to write a program having a class FacebookLikeManager with the three public methods as mentioned in the question.

Since you haven't mentioned the programming language. I am choosing python for the same.

We could use a python dictionary data structure to implement this.

 

 

Algorithm 

  1. Create a file users.txt with the data given in the question.
  2. Declare the class
  3. Convert the text file to a dictionary as a class variable
  4. Initialize the class using a constructor taking text file
  5. Declare methods using basic operations and data structures in python
  6. Instantiate a class object and check the working of the methods.
  7. Stop

 

steps

Step by step

Solved in 5 steps with 3 images

Blurred answer
Knowledge Booster
Unreferenced Objects
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education