Python For this assignment, you will write a program to allow the user to store the names and phone numbers of their contacts. Create the following classes: Contact: two attributes. One for the contact's name and the contact's phone number. Node: two attributes: _data and _next. For use in a linked list. ContactList: One attribute: _head, a reference to the head of an internal linked list of Node objects. Note: self._head is an attribute of the class, so any method which updates the internal linked list can simply update the list self._head references. There is no need to return anything like we did in methods such as add_to_end in the lecture. Note also that for the same reason, we do not have to pass a reference to the head of the list to any method, because each method should already have access to the self._head attribute. ContactList should also have the following methods: add(name, new_number). Creates a new Node with a Contact object as its _data. The new Node is then added to ContactList's internal linked list referenced by _first_node. This will be a little different from what we've seen so far, because the Contacts should remain sorted in alphabetical order. When a Node is added to the linked list, find its correct location based on the Contact it holds and place the Node there. Do not worry about sorting by last name, just by overall name i.e., "Ryan Adams" should go after "Jill Smith". String objects in Python can be tested for alphabetical ordering with the > and < operators. Override __str__ so that it returns a nicely formatted string with each Contact's name and phone number. remove(name). Remove the Contact with the given name from the list, if it exists. change_phone_number(name, new_number). Update the phone number of the contact with the given name, if it exists. On main.py, create a ContactList object and then write a menu-based while loop that gives the user five options: add, remove, change phone number, print contacts, and quit. Make sure to test as many corner cases as possible (i.e., does it work when you remove the first Contact? How about the last Contact? etc.) Note: You are not required to perform a sort on the list! When you add a new Contact, the method only needs to find the correct location for that particular object. For example, if the user adds 'Bob' to an empty ContactList, it becomes the first (and only) Contact. If the user then adds 'Adam', it becomes the new head of the list (since it comes before 'Bob' alphabetically). Finally, if the user adds Barb, the list should be Adam ->Barb ->Bob. Hint: each call to 'add' only adds a single Contact to a list which is already in sorted order.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question
Python For this assignment, you will write a program to allow the user to store the names and phone numbers of their contacts. Create the following classes: Contact: two attributes. One for the contact's name and the contact's phone number. Node: two attributes: _data and _next. For use in a linked list. ContactList: One attribute: _head, a reference to the head of an internal linked list of Node objects. Note: self._head is an attribute of the class, so any method which updates the internal linked list can simply update the list self._head references. There is no need to return anything like we did in methods such as add_to_end in the lecture. Note also that for the same reason, we do not have to pass a reference to the head of the list to any method, because each method should already have access to the self._head attribute. ContactList should also have the following methods: add(name, new_number). Creates a new Node with a Contact object as its _data. The new Node is then added to ContactList's internal linked list referenced by _first_node. This will be a little different from what we've seen so far, because the Contacts should remain sorted in alphabetical order. When a Node is added to the linked list, find its correct location based on the Contact it holds and place the Node there. Do not worry about sorting by last name, just by overall name i.e., "Ryan Adams" should go after "Jill Smith". String objects in Python can be tested for alphabetical ordering with the > and < operators. Override __str__ so that it returns a nicely formatted string with each Contact's name and phone number. remove(name). Remove the Contact with the given name from the list, if it exists. change_phone_number(name, new_number). Update the phone number of the contact with the given name, if it exists. On main.py, create a ContactList object and then write a menu-based while loop that gives the user five options: add, remove, change phone number, print contacts, and quit. Make sure to test as many corner cases as possible (i.e., does it work when you remove the first Contact? How about the last Contact? etc.) Note: You are not required to perform a sort on the list! When you add a new Contact, the method only needs to find the correct location for that particular object. For example, if the user adds 'Bob' to an empty ContactList, it becomes the first (and only) Contact. If the user then adds 'Adam', it becomes the new head of the list (since it comes before 'Bob' alphabetically). Finally, if the user adds Barb, the list should be Adam ->Barb ->Bob. Hint: each call to 'add' only adds a single Contact to a list which is already in sorted order.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 6 steps with 4 images

Blurred answer
Knowledge Booster
Types of Linked List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education