Use of procedures, parameter passing, block structures, data types, arrays, abstract data structures, conditional control, iterative and recursive processes, and input/output in programming solutions to a variety of problems. Prerequisite: None.

Lab 8 - Introduction to Classes - (50 points)



Due date: 4/30/2019 at 11:59pm

Objectives



  • Introduction to Classes and Objects
  • Practice with files and lists

For this lab, write a program to manage an address book that contains contact information about contacts stored in a file.

  • Create an Individual class that contains the name, phone number, address, and email address as the data attributes. Make sure to create the constructor, the getters/setters, and the __str__() method for the class. (10 points)
  • Create a contact information file such that all the information for an individual is on a single line as follows:

    			    Grace Hopper, 123-456-7890, New York, grace@harvard.edu
    			    Anita Borg, 111-111-1111, Chicago, anita@wit.org
    			    Ada Lovelace, 000-010-1010, London, ada@analytical.uk
    			    Katherine Johnson, 826-100-1918, Hampton, katherine@nasa.gov				    
    				  
  • Create a python program addressbook.py that will read the filename provided at the command line (5 points). For example, the program should run as follows: python3 addressbook.py contacts.txt.
  • For each individual, create a new individual object and add it to a list so you can perform print and search operations on it. (15 points)

The program should contain the following options for interacting with the address book.

  1. Display all the individuals in the address book (10 points)
  2. Search for an individual in the address book based on the name of the individual. The search should work in such a way that if the name is stored as "Mickey Mouse" and the user entered only "Mickey", it should still show all the details for that individual. (10 points)
  3. Exit the program

Extra credit (5 points)



Add contact information for a new individual to the list and write it to the file when exiting the program so that when you close the program, the new individual's information is written out to the file.

Submitting the lab using submit directory



Submit the following files on Canvas

  • The python file containing the class
  • addressbook.py
  • README file