Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# ----------------------------------------------------- # CSCI 127, Lab _ # Month __, 20__ # Firstname Lastname # # A description of this program # ----------------------------------------------------- class Contact:

image text in transcribed

image text in transcribed

# ----------------------------------------------------- # CSCI 127, Lab _ # Month __, 20__ # Firstname Lastname # # A description of this program # -----------------------------------------------------

class Contact: """Contact class for representing and manipulating contacts"""

def __init__(self, first, last, phone): """A constructor to initialize Contact attributes""" pass # TODO: initialize contact attributes first_name, last_name, title, full_name, phone_number

# TODO: add getter and setter methods

def print_entry(self): """method to print contact""" space = 50 - len(self.full_name) print(self.full_name + self.phone_number.rjust(space, '.')) # ----------------------------------------------------- # Do not change anything below this line # -----------------------------------------------------

def print_directory(contacts): print("CONTACTS".center(50, '-')) for person in contacts: person.print_entry() print("".center(50, '-'))

# -----------------------------------------------------

def search_contacts(contacts):

search_string = input("Search for contact: ") found = False if search_string == "": return 0 for contact in contacts: if (search_string.lower() in contact.get_full_name().lower()): contact.print_entry() found = True if (search_string.lower() in contact.get_phone_number().lower()): contact.print_entry() found = True if not found: print("Search string not found.") # -----------------------------------------------------

def main(): prof = Contact("Daniel", "DeFrance", "406-994-1624") mascot = Contact("Bobcat", "", "unlisted") mascot.set_first_name("Champ") cs_dept_head = Contact("John", "Paxton", "406-994-5979") cs_dept_head.set_title("Department Head") president = Contact("Waded", "Cruzado", "406-994-CATS") president.set_title("President") contacts = [prof, mascot, cs_dept_head, president] done = False while not done: print() user_input = input("[P]rint contacts, [S]earch contacts, [Q]uit: ") if user_input.lower() == 'p': print() print_directory(contacts) elif user_input.lower() == 's': print() search_contacts(contacts) elif user_input.lower() == 'q': done = True else: print("Enter P, S, or Q") # -----------------------------------------------------

main()

Lab 7: OOP Contacts App Logistics Partner Information: Complete this assignment individually. Submission Instructions: Upload your solution, renamed to Your FirstName- YourLastName-Lab7.py to the BrightSpace Lab 7 Dropbox. . Deadline Reminder: Once this deadline passes, BrightSpace will no longer accept your Python submission and you will no longer be able to earn credit. Thus, if you are not able to fully complete the assignment, submit whatever you have before the deadline so that partial credit can be earned. Learning Outcome Gain experience with object oriented programming and formatting output. Assignment A smartphone's contacts app has the ability to save contact information. In this assignment, you will simulate the contact list for a very simple contacts app. Download lab7.py below, rename it according to the instructions above, and make sure you understand it. Take the program above and modify it by completing the missing Contact class such that when the program is run, it can produce the sample transcript output Hint: for help on formatting output, revisit the online textbook's chapter 9.5.1 Grading - 10 points . 2 points - The constructor of the Contact class is correct. (initializes the following 5 attributes): self.first_name self.last_name self.full_name o self.phone_num self.title (this should be initialized to the empty string) 2 points - The getter methods of the Contact class are correct (a getter for all five attributes) . 2 points - The setter methods of the Contact class are correct (a setter for four attributes -- all but full_name) . 4 points - Your program's output matches the output format of the transcript below (1 point for each type of difference up to 4 points). [P]rint contacts, [S]earch contacts, [Q]uit: p -CONTACTS- John Smith. Champ.. Jakob Mcnush, Department Head. Tyler King, President... 1406-994-1624 ...unlisted .406-994-5979 .406-994-CATS [P]rint contacts, [S]earch contacts, [Q]uit: s Search for contact: dan John Smith.. ..406-994-1624 [P]rint contacts, [S]earch contacts, [Q]uit: s Search for contact: 99 John Smith. . . . . . Jakob Mcnush, Department Head. Tyler King, President... .406-994-1624 406-994-5979 ..406-994-CATS [P]rint contacts, [S]earch contacts, [Q]uit: s Search for contact: [P]rint contacts, [S]earch contacts, [Q]uit: 9

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions