CSE 231代写、代做Python编程设计

- 首页 >> OS编程
CSE 231 Spring 2025
Computer Project 07
1. Assignment Overview (learning objectives)
This assignment focuses on the design, implementation and testing of a Python program which uses classes to
solve the problem described below. Note: you are using a class we provide. You will develop a program that
allows the user to interact with the VibeNet platform, a Python-based social media platform supplied by
instructors.
This assignment will give you more experience in reading code and the use of:
● Dictionaries
● Functions
● Classes and OOP
Prohibitions:
• You are NOT allowed to use global variables.
• You are ONLY allowed to use concepts up to and including week 13.
2. Important Note about submission
3. Assignment Deliverable
• We provide a zip file on the course website that you need to download into your computer, unzip the
file, and open it in PyCharm (similar to the lab) to access the starter code.
• Every project has a video and a document to get you started with the project. The video is posted on the
same page of the course website as the instructions. Watch the project video for more help with the
problem-solving part.
• To finalize and submit your code:
1- Click on the assignment link in D2l for the first time.
2- Write or copy your code in CODIO in the tab named proj07.py
3- Click on the button “Code Co@ch Buddy”. This will grade your assignment. Then, a window
appears with your grade information. Expand the window to see the details and explanations. Click
on the links (pink or blue) to get feedback on your assignment. You can then use the feedback to
improve your grade.
4- Once you are satisfied with your work, make sure to click on “Mark as Completed” to submit your
code and avoid any late penalties.
This assignment is worth 50 points (5.0% of course grade). It must be completed before 11:59 PM EST on Monday,
April 14th.
After the due date (04/14), your score will be deducted by 2% for every 1 hour late or a fraction of it. No
submissions will be accepted after 24 hours from the due date. Penalty will be applied on the full project score.
The project will be automatically submitted by the due date (04/14). If you want to keep working on it after the
deadline with penalty, you must manually click on “Mark as uncompleted”, acknowledge the penalty message and
manually click on “Mark as completed” when done.
4. Assignment Specifications and Requirements
4.1. General Requirements
These are general requirements that you need to satisfy to ensure a full score:
1. Items 1-9 of the Coding Standard will be enforced for this project:
http://www.cse.msu.edu/~cse231/General/coding.standard.html
2. Per the syllabus, if you "hard code" answers, you will receive a grade of zero for the whole project.
3. You should only use materials covered in class up to week 13 (videos and textbook).
4. You have to implement at least 12 functions.
a. A good practice is to have functions that perform one task at a time. It makes your code more
readable.
b. Any function that you create needs to be used in your code.
c. There must be a function named main()(check section .2.2 for more details about the project
specifications). The main function is called by:
d. There must be at least 11 other functions that do something meaningful (it is good to have more
functions).
4.2. VibeNet: A Social Media Platform (provided in vibenet.py)
VibeNet is a Python-based social media platform that enables users to
create, share, and engage with content. The platform allows users to post
updates, interact with other users through likes and comments, search for
content based on hashtags or dates, and maintain a personal profile with
follower statistics. The system is designed with an emphasis on
engagement, and user interaction:
● User Authentication and Management
o Users can sign up with a unique username and password.
o Users can login with authentication.
● Content Creation and Interaction
o Users can create new posts with textual content.
o Posts have attributes such as likes, comments, and engagement scores.
o Users can like and comment on posts.
o Comments are stored and displayed with user information.
● Post Management
o Users can edit and delete their own posts.
o Posts include metadata such as creation date and author.
● Search and View Newsfeed
o Search posts by hashtags.
o Search posts within a date range.
o View newsfeed sorted by engagement score and date.
if __name__ == '__main__':
main()
● Other Features
o Profile page displaying user details and created posts.
o List of all users sorted by popularity.
o Posts and user information are loaded from external files.
These are the classes that are provided in the vibenet.py, and you have to use the attributes and the methods.
Make sure to go through the file and understand the methods in each class. Otherwise, you will not be able to
understand what you should do.
Post Class:
● Purpose: Represents a social media post.
● Attributes:
o post_id: Unique identifier for the post. (will be incremented by 1 for new posts)
o user_id: ID of the user who created the post.
o content: Text content of the post.
o like_count: Number of likes on the post.
o comment_count: Number of comments on the post.
o comments: List of comments on the post.
o date: Date when the post was created. (April 14, 2025 for new posts)
o author: Username of the post creator.
● Methods:
o get_engagement_score(): Calculates the post's engagement score.
(like_count * 0.5 + comment_count * 1)
o edit_content(): Allows the author to edit the post.
o can_modify(): Checks if a user has permission to modify the post.
User Class:
● Purpose: Represents a user on the VibeNet platform.
● Attributes:
o user_id: Unique identifier for the user. (will be incremented by 1 for new users)
o username: User's chosen username.
o password: User's password. (follows some constraints)
o followers: Number of followers. (0 for new users)
o following: Number of users being followed. (0 for new users)
o posts: Dictionary of user's posts.
● Methods:
o display_profile(): Displays user profile information.
VibeNet Class:
● Purpose: Manages users, posts, and interactions within the platform.
● Attributes:
o users: Dictionary mapping user IDs to User objects.
o posts: Dictionary mapping post IDs to Post objects.
● Methods:
o read_users_file(): Loads user data from users.txt file.
o read_posts_file(): Loads post data from posts.txt file.
o search_posts_by_date(): Finds posts within a given date range.
o add_user(): Registers a new user.
o add_post(): Creates a new post.
o display_user_posts(): Displays all posts by a specific user.
o get_user(): Retrieves a user by their ID.
4.3 Your tasks: proj07.py
You will develop a program that allows the user to interact with the VibeNet platform. The program will use the
instructor-supplied vibenet.py module to design the posts, the users and the vibenet platform. To help
clarify the specifications, we provide sample output of a correctly implemented python program below in the
Sample Output section. We also provide a proj07.py file that contains the starter code. Your program must
use the import statement for vibenet.py. You should not modify the vibenet.py file otherwise you will
not pass the tests as we will be using our own vibenet.py file that is identical to the file provided in the
starter code.
Creating the platform:
You are provided with three data files. The hidden tests will use the same files. You should create a VibeNet
object using the following 3 files:
1. users.txt: contains user ID, user name, password, followers’ count, number of profile that
the users are following.
2. posts.txt: contains post ID, user ID who posted, post content, like count, comment count,
and date.
3. post_comments.txt: contains post ID, names of the users who commented, and comments.
In this assignment, you will implement the necessary functions to run a complete social network platform using
the pre-defined classes. Your project should implement the following features:
1. Log in:
○ Prompt the user to enter their user ID. Check if the entered user ID exists in the vibenet users
dictionary. If the user ID is not found, display an error message. If found, proceed to the next
step.
○ Prompt the user to enter their password. Retrieve the corresponding User object and verifie if the
entered password matches the stored password. If the password is incorrect, display an error
message. If login is successful, allow the user to interact with the system.
2. Sign up:
○ Prompt the user to enter username and password and validate the password.
○ A valid password must:
i.Be at least 8 characters long.
ii.Contain at least one uppercase letter.
iii.Contain at least one lowercase letter.
iv.Contain at least one digit.
v.Contain at least one special character (e.g., @, #, $, %, etc.).
○ If the password does not meet these criteria, prompt the user to re-enter a valid password.
○ Generate a unique user_id and create a new User object and add the new user to the vibenet users
dictionary.
○ Print a success message and display the new user's profile.
○ Allow the new user to interact with the system.
3. Create Post:
○ Prompts the user to enter the content of the post.
○ If the content is empty, display an error message.
○ Generate a unique post_id and create a new Post object with the given user_id and content.
○ Add the post to the vibenet posts dictionary and associate it with the user’s posts dictionary.
4. View Profile:
○ Retrieve the User object corresponding to the logged-in user.
○ Calls appropriate method of the User class to show: User ID, username, number of followers,
and number of users they are following, all posts created by the user.
○ The user should be able to: Edit and delete a post only if the user has created any post
5. Edit Post:
○ Prompt the user to enter the post_id of the post they want to edit and verify if the post_id exists
and if the user has permission to modify it.
○ Display the current content of the post and prompt the user to enter new content.
○ If the new content is empty, display an error message.
6. Delete Post:
○ Prompt the user to enter the post_id of the post they want to delete and verify if the post_id exists
and if the user has permission to delete it.
○ Remove the post from vibenet posts and from the user’s posts dictionary.
7. Search Posts by Tag:
○ Prompt the user to enter a hashtag keyword without # symbol. If the tag is empty, display an
error message.
○ Search through vibenet posts to find posts containing the entered hashtag.
○ If no posts are found, display a message.
○ If posts are found, display them sorted by likes and comment count in descending order.
8. View Newsfeed:
○ Retrieve all posts and sorts them by: engagement score in descending order (likes * 0.5 +
comments * 1.0) and Date (newer posts first)
○ Display each post, including the engagement score.
○ After displaying the newsfeed, the user should have options to: like a post or comment on a post
9. Like a Post:
○ Prompt the user to enter a post_id. If the post_id exists, increment the like_count. If the post_id
is invalid, display a message.
10. Comment on a Post:
○ Prompt the user to enter a post_id. Check whether the post id valid.
○ If the post_id exists, prompt them to enter a comment.
○ Append the comment to the post’s comments list, increment comment count,
11. View Users:
○ Retrieve all users and sort them by the number of followers and the number of following
users in descending order and show them
12. Search Posts by Date:
○ Prompt the user to enter a start date and end date in YYYY-MM-DD format.
○ Use the appropriate method from the classes given to get the posts in that range
○ If posts are found, display them sorted by date (newest first).
Hints:
● Do not modify the vibenet.py file in any case.
● Keep in mind to use the appropriate methods of the classes. There are lots of functionalities already
implemented for you.
● Add the beginning of the program, call proper methods of VibeNet class to load data from the files.
● Utilize the can_modify method under Post class when needed.
● You can use ch.isalnum()to check whether ch is a symbol or not.
5. Grading Rubric
Computer Project #07 Scoring Summary
General Requirements:
(5 pts) Coding Standard
(12 pts) At least 12 function definitions
Implementation: 33 points total.
Test Case 0 and 1: Visible
Test Case 2 and 3: Hidden
More points are allocated to the hidden test. The visible tests serve as a self-check. To pass all
tests, you need to follow the complete instructions in the PDF.
Note:
1. hard coding an answer earns zero points for the whole project.
2. Use of any advanced data structures not covered in class earns zero points for the whole
project.
6. Sample Output
The outputs for Test 0 and Test 1 are in the output0.txt and output1.txt

站长地图