Question: A simple Database using OOP Defining the Problem Let's say you created a social networking website and users are signing up on your website. A

 A simple Database using OOP Defining the Problem Let's say you
created a social networking website and users are signing up on your
website. A lot of users are signing up, so you need a
way to create a simple database for users and their credentials. Using

A simple Database using OOP Defining the Problem Let's say you created a social networking website and users are signing up on your website. A lot of users are signing up, so you need a way to create a simple database for users and their credentials. Using the Object Oriented Programming (OOP) concepts you learned in the class this week, create a simple database that stores/deletes user credentials in/from a file named database.txt. The file database.txt has already been created for you. Task 1 You are required to store the user credentials everytime a new user sign ups. Each user will have a username, email, and password as attributes. Save them as instance attributes self.name . self.email and self.password when the object is created. Also write these credentials into the file named database.txt. You should write the credentials of a user on a single line using this format username, email, password (no whitespaces in between). Please refer to example section for how the content of file should look like. Task 2 Now you have created a database with user credentials but you also want to delete the user credentials from your database if a user deletes their account So, write a destructor to clear the attributes of the user and remove the user from your database file, database.txt as well when a user deletes their account Complete the code provided in my_user.py. Please do not change the name of the class. Note: The order of attributes while signing up are username, email, and password i.e. your constructor Task 2 Now you have created a database with user credentials but you also want to delete the user credentials from your database if a user deletes their account. So, write a destructor to clear the attributes of the user and remove the user from your database file, database.oxt as well when a user delete their account Complete the code provided in my_user.py. Please do not change the name of the class Note: The order of attributes while signing up are username, email, and password i.e. your constructor must take the arguments in the provided order. You may also assume that emails for each user instance are unique. Please refer to the example below for more information on adding/deleting to/from the database Example Action: Add user, User("testuser", "testte Database: testuser, test@test.com, testpassword Action: Add user, User("compsci", "cs@test. Database: testuser, test@test.com, testpassword compsci, cs@test.com, compscipassword Action: Add user, User("testuser", "oopates Database: testuser, test@test.com, testpassword compsci, cs@test.com, compscipassword testuser, oop@test.com, ooppassword Action: Delete compsci user, del instance Database: testuser, test@test.com, testpassword testuser, oop@test.com, ooppassword LOOP 1 Your code OOP database my_user.py class User: Write your code below pass 1 2 3 4 5 6- 7 8 (Optional) Add your custon test cases under this statement 11 nane.main_.": Your custom test cases o here pass

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!