MCS-178 Project 7: A Text Version of Facebook (Fall 2024)

Start: Tuesday, 12/3; Due: Monday, 12/16, by midnight, no late projects will be accepted!!!


Overview

In this project, you will experiment with building your own Python classes to work with existing classes (written by students in MCS-177). You will also work on unit testing and drawing UML diagrams.

Many of you log into Facebook and interact with your friends. Collaborating with MCS-177 students in your group, you will put together a program that represents a text-version of Facebook.

Overall Example

Here is an example of how all the classes come together to make our Facebook work.

>>> TextFacebook = Facebook()
>>> TextFacebook.registerUser('Bob', 'bob@gmail.com')
>>> TextFacebook.registerUser('Alice', 'alice@gac.edu')
>>> TextFacebook.registerUser('Charles', 'charlie@hotmail.com')
>>> TextFacebook.login('Bob')
>>> TextFacebook.addFriend('Alice')
>>> TextFacebook.postStatus('is working on Project 10!')
>>> TextFacebook.viewStatus()
(0) Bob is working on Project 10!
>>> TextFacebook.logout()
>>> TextFacebook.login('Charles')
>>> TextFacebook.addFriend('Alice')
>>> TextFacebook.postStatus('is going to watch Star Trek Into Darkness.')
>>> TextFacebook.viewStatus()
(1) Charles is going to watch Star Trek Into Darkness.
>>> TextFacebook.logout()
>>> TextFacebook.login('Alice')
>>> TextFacebook.viewProfile()
Alice (alice@gac.edu)
Friends: Bob and Charles
>>> TextFacebook.viewStatus()
(0) Bob is working on Project 10!
(1) Charles is going to watch Star Trek Into Darkness.
>>> TextFacebook.likeStatus(1)
>>> TextFacebook.viewStatus()
(0) Bob is working on Project 10!
(1) Charles is going to watch Star Trek Into Darkness.
Alice likes this.
>>> TextFacebook.commentOnStatus(0, 'Poor you... Have a cookie!')
>>> TextFacebook.viewStatus()
(0) Bob is working on Project 10!
Alice: Poor you... Have a cookie!
(1) Charles is going to watch Star Trek Into Darkness.
Alice likes this.
>>> TextFacebook.logout()
>>> TextFacebook.login('Bob')
>>> TextFacebook.viewStatus()
(0) Bob is working on Project 10!
Alice: Poor you... Have a cookie!
>>> TextFacebook.commentOnStatus(0, "It's all right. The project is a lot of fun!")
>>> TextFacebook.postStatus("finished working on Project 10! Woohoo!")
>>> TextFacebook.logout()
>>> TextFacebook.login('Alice')
>>> TextFacebook.viewStatus()
(0) Bob is working on Project 10
Alice: Poor you... Have a cookie!
Bob: It's all right. The project is a lot of fun!
(1) Charles is going to watch Star Trek Into Darkness.
Alice likes this.
(2) Bob finished working on Project 10! Woohoo!

Task 1: Unit Tests For the Comment Class

First, carefully read this entire page, including the grading criteria at the bottom of the page.

The Comment (comment.py) class is going to be written by the MCS-177 students in your group. Please work with them to finish the code (you need their code in order to do task 3 and task 4 of this project). The implementation of the Comment class in comment.py is as follows:

Once you had helped the MCS-177 students in your group to finish the Comment class (comment.py), you will need to make sure that the Comment class works and behaves the way you want it to (as you will need to later write code that works with the Comment class). Create a main.py class for unit testing for the Comment class. The example given above can be a part of your unit tests. Please be sure to cover all of the exception cases and give tests for at least two normal cases. You will also need to write comments labeling each of your test cases. Please work with the MCS-177 students in your group for the testing (as they also need to do these tests in their project).

Task 2: Unit Tests For the Status Class

Similarly, the Status (status.py) class is going to be written by the MCS-177 students in your group. The implementation of the Status class in status.py is as follows:

Once you had helped the MCS-177 students in your group to finish the Status class (status.py), you will need to make sure that the Status class works and behaves the way you want it to (as you will need to later write code that works with the Status class). In the main.py class, add unit testing for the Status class. The example given above can be a part of your unit tests. Please be sure to cover all of the exception cases and give tests for at least two normal cases. You will also need to write comments labeling each of your test cases. Please work with the MCS-177 students in your group for the testing (as they also need to do these tests in their project).

Task 3: Implementing the User Class

Given the Comment class and the Status class that were provided to you. You are to implement the User class in user.py such that:

Provide unit testing for the User class in your main.py. Please be sure to cover all of your exception cases and give tests for at least two normal cases. You will also need to write comments labeling each of your test cases.

Task 4: Implementing the Facebook Class

Implement the Facebook class in facebook.py such that:

Provide unit testing for the overall Facebook class in your main.py. Please be sure to cover all of your exception cases and give tests for at least two normal cases. You will also need to write comments labeling each of your test cases.

Task 5: Drawing the UML Diagram

Now that you have the Facebook program completed, provide the UML diagram for it. Please be sure to draw all of the classes, the instance variables, the functions, and the relationship between classes.

Note

Remember not to print anything in the __str__ method. You should accumulate ONE string that contains all the information and return it.

Submitting your work

You will be submitting your code using Moodle. Be sure to select 2025 f-mcs-178-001, which is your lecture section, then click on the MCS-178 Project 7 Submission link. For this project, you will need to submit the following files:

Grading

You will earn one point for each of the following accomplishments:

  1. All exception cases and normal cases were tested in main.py for the Comment class; comments were given labeling each test case (5 pts).

  2. All exception cases and normal cases were tested in main.py for the Status class; comments were given labeling each test case (5 pts).

  3. All exception cases and normal cases were tested in main.py for the User class; comments were given labeling each test case (5 pts).

  4. All exception cases and normal cases were tested in main.py for the Facebook class; comments were given labeling each test case (5 pts).

  5. The overall UML diagram for the program is drew correctly (10 pts).

  6. You have all the instance variables necessary for the User class (5 pts).

  7. You have all the accessor and mutator methods for all the instance variables in the User class (5 pts).

  8. The __str__ method in the User class formats the code correctly (5 pts).

  9. The addFriend method links two users as friends correctly in the User class (5 pts).

  10. The isFriend method checks if the given user is a friend or not correctly (5 pts).

  11. The __str__ method of the user class uses the grammatically correct format (5 pts).

  12. You have all the instance variables necessary for the Facebook class (5 pts).

  13. The registerUser method adds a new user to Facebook correctly (5 pts).

  14. The login and logout methods log in and out a user correctly and print out an error message when appropriate (5 pts).

  15. The addFriend method correctly links two users as friends in the Facebook class (5 pts).

  16. The viewProfile method displays the information about the current user correctly (5 pts).

  17. The viewStatus method displays only the status of the currently logged-in user and his/her friends, formatting the statuses correctly and printing out an error message when appropriate (5 pts).

  18. The postStatus method adds a new post by the user correctly. It prints out an error message when appropriate (5 pts).

  19. The likeStatus and commentOnStatus methods behave correctly. They print out an error message when appropriate (5 pts).


Total: 100 pts