Docsity

Programming Assignment 8 - Introduction to Computer Science--CS 2 | CS 1410, Assignments of Computer Science

Toggle sidebar
bg1
1
CS 1410 Introduction to Computer Science – CS2
Section 2: MWF 9:30 a.m. – 10:20 a.m.
Instructor: Xiaojun Qi
Programming Assignment #8
Given: March 20, 2009
Due Date: April 1, 2009
Submit electronically via the eagle system before 11:59 p.m.
Total Points: 30 points
Write a program to maintain a phone book. The phone book is to be maintained as a linked list
in an ascending order based on the name of the entry. Your linked list must follow the
design I showed in class.
Write a linked list class, which provides the following methods and features:
• Insert: Add an entry in the list in the ascending order based on the name of the entry.
• Delete: Delete an entry from the list.
• Find: Return true if the item is found in the list and print out the information related to the
item. Return false if the item is not found in the list and print “not found”.
• Print: Print the address book stored in the linked list.
• Size: Return a count of the number of entries in the list
• Overloaded = operator: Makes a copy of the list to another list
• Overloaded [] operator: Returns the name together with the phone number at the position
specified.
• Copy constructor.
Note: The Insert operation does not allow duplicates. If a duplicate name is attempted for
insertion, throw an exception class named: DuplicateException.
Your program must accept the following input for each of the following operations, namely,
insert, delete, and find operations. Note that the pointy brackets, < and > indicate user defined
input and are not typed in the input.
Insert: <name> # <phone-number>
<name> can be a string of any of the 26 letters (i.e., it does not contain the “#” character).
<phone-number> can be any string which contains any combination of 10 digits. Create
an entry with the corresponding values and add it to the address book.
For example, insert Xiaojun Qi#4351234567 should add an entry with name “Xiaojun
Qi” and phone number 4351234567 to the phone book.
Find: <string>
If there is an entry with a name field that contains the given string, print the entire entry.
If not, print “not found”.
pf2

Partial preview of the text

Download Programming Assignment 8 - Introduction to Computer Science--CS 2 | CS 1410 and more Assignments Computer Science in PDF only on Docsity!

CS 1410 Introduction to Computer Science – CS Section 2: MWF 9:30 a.m. – 10:20 a.m. Instructor: Xiaojun Qi Programming Assignment #

Given: March 20, 2009 Due Date: April 1, 2009 Submit electronically via the eagle system before 11:59 p.m. Total Points: 30 points

Write a program to maintain a phone book. The phone book is to be maintained as a linked list in an ascending order based on the name of the entry. Your linked list must follow the design I showed in class.

Write a linked list class , which provides the following methods and features:

  • Insert: Add an entry in the list in the ascending order based on the name of the entry.
  • Delete: Delete an entry from the list.
  • Find: Return true if the item is found in the list and print out the information related to the item. Return false if the item is not found in the list and print “not found”.
  • Print: Print the address book stored in the linked list.
  • Size: Return a count of the number of entries in the list
  • Overloaded = operator: Makes a copy of the list to another list
  • Overloaded [] operator: Returns the name together with the phone number at the position specified.
  • Copy constructor.

Note: The Insert operation does not allow duplicates. If a duplicate name is attempted for insertion, throw an exception class named: DuplicateException.

Your program must accept the following input for each of the following operations, namely, insert, delete, and find operations. Note that the pointy brackets, < and > indicate user defined input and are not typed in the input.

Insert: # <phone-number> can be a string of any of the 26 letters (i.e., it does not contain the “#” character). <phone-number> can be any string which contains any combination of 10 digits. Create an entry with the corresponding values and add it to the address book. For example, insert Xiaojun Qi#4351234567 should add an entry with name “Xiaojun Qi” and phone number 4351234567 to the phone book.

Find: If there is an entry with a name field that contains the given string, print the entire entry. If not, print “not found”.

For example, find Xiaojun or find Qi should find an entry and print out the information related to the entry.

Delete: Delete the entry of the phone book corresponding to the name. For example, delete Xiaojun Qi or delete xiaojun qi should delete the entry for the name “Xiaojun Qi”. The name must match exactly for the deletion operation. If no such name exists, print a message indicating that there is no one by that name.

You must write a driver program with the menu options that calls the appropriate functions to implement the aforementioned functionalities and completely demonstrates you have correctly implemented the requirements.