Question: programming language python check for test case Write a class Contacts for a contacts book, with the following attributes (make sure the attributes are private

 programming language python check for test case Write a class Contacts
programming language python
for a contacts book, with the following attributes (make sure the attributes
check for test case

Write a class Contacts for a contacts book, with the following attributes (make sure the attributes are private using name mangling): owner: String names : List of Strings -- names in the contacts book emails: List of Strings -- emails of the contacts The class must include the following operations: A constructor that receives as input the owner. Getters for each attribe. new_contact(name: String, email: String): Bool This operation adds the person's name to the list of names and the email to the list of emails. The method must check whether the email contains the '@' character, if it does not then the contact (name and email) won't be added. The method must return True if the new contact was added, False otherwise. _str_0 -- Should return the following information "cowner> is the owner of this notebook, which has contacts". Check the testcase for more format details. update_contact(name: String, email: String): Bool This operation updates the person's the email in the list of emails. Update means replacing the existing email with the one provided to the method. The method must check whether name exists in the list of names and if the new email contains the '@' character, both conditions must hold for the contact to be updated. The method must return True if the contact was updated, False otherwise, remove_contact(name: String): Bool This operation removes the person's name and email from the corresponding lists. The method must return True if the contact was removed, and False if the contact was not in the names list. contacts_from_file(filename: String) -- Reads the contact names and emails from a text file and adds them to the corresponding lists. The file has one NEBER Accessdeck Old-Moodle English (en) be updated. The method must return True if the contact was updated, False otherwise. remove_contact(name: String): Bool -- This operation removes the person's name and email from the corresponding lists. The method mu return True if the contact was removed, and False if the contact was no the names list contacts_from_file(filename: String) -- Reads the contact names and er from a text file and adds them to the corresponding lists. The file has or name-email per line separated by a semicolon. You must check wheth the email contains the '@' character, if it does not then that specific contact shouldn't be added. You can assume the filename passed as parameter does exist (i.e. you do not have to check if the file exists). For example: Result Ludwig 0 Cing constructor and getters Ets = Contacts("Ludwig") contacts.get_owner() contacts.get_names()) contacts.get_emails()) ing new_contact method its = Contacts("Ahmed") its.new_contact("Norton", "peter_n@gmail.com") its.new_contact("Felipe", "felipe_com") contacts.get_names()) contacts.get_emails()) I'Norton'] I'peter_n@gmail.com Answer: Inenalty recimo:09

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!