In c++ with proper headers, I cannot figure out how to convert the original arra
ID: 3915780 • Letter: I
Question
In c++ with proper headers, I cannot figure out how to convert the original array based assignment to the linked list version.
/////////////////
This is the new assignment
Using classes and linked lists, design an Online Address Book to keep track of the names, addresses,phone numbers, and dates of birth of family members, close friends, and certain business associates.Your program should be able to handle as many entries as required.
1. By the Assignment 2, you have created the user defined data type extPersonType
2. Define the class addressBookType to built a linked list. The value of each node has the type of extPersonType . An object of the type addressBookType
should be able to process as many entries each of them as required.
3. Write a C++ program to test your design. The program should perform the following operations:
Add a new entry to a address book.
Delete an entry from a address book.
Print the value of each node of a address book.
//////////////////////////////////////////////////////////////////////////
This was the previous assignment.
Using classes and arrays, design an Online Address Book to keep track of the names, addresses, phone numbers, and dates of birth of family members, close friends, and certain business associates.
Your program should be able to handle as many entries as required.
1. Define a class,addressType, that can store a street address, city, state, and ZIP code. Use the appropriate functions to print and store the address. Also, use constructors to automatically initialize the member variables.
2. Define a class, personType , that can store the first name and the last name of a person. Use e appropriate functions to print and store the first and the last name. Also, use constructors to automatically initialize the member variables.
3. Define a class, dataType, that can store the day, the month, and the year of a date. Use the appropriate functions to print and store the day, the month, and the year. Also, use constructors to automatically initialize the member variables.
4. Define a class extPersonType . The class is a derived class from the above classes. The class adds a member variable to classify the person as a family member, friend, or business associate. Also, the class adds a member variable to store the phone number. Moreover, the class adds (or override ) fuctions to print and store the appropriate information. Use constructors to automatically initialize the member variables.
5. Define the class addressBookType using the previously defined classes. An object of the type addressBookType should be able to process as many entries as required.
6. Write a C++ program to test your design. The program should perform the following operations:
–
Add a new entry to the address book.
–
Delete an entry from the address book.
–
Print all the information of the address book
Explanation / Answer
A linked list is composed of many "nodes" which are connected to each other either one way (singly linked list) or both ways (doubly linked list). Every node is mainly divided into two fields, one field holds the data and the other field holds the pointer to the next node The Array and Linked List implementation of addressBookType will differ in the implementation of add, delete and print/data structure traversal methods : ?ADD : To add an entry to a linked list, the entry corresponding to the current tail pointer is modified to point to the new entry and the tail pointer now points to this new entry DELETE : To delete an entry from a linked list, the previous entry will simply point to the entry pointed to by the entry to be deleted. PRINT : Starting from the head node, the data of each node can be printed on traversal Here is an implementation outline for the add method for eg. : using namespace std; struct ExtPersonType { int data; ExtPersonType *next; }; class AddressBookType { private: ExtPersonType *head,*tail; public: AddressBookType() { head = NULL; tail = NULL; } void insertAtEnd(ExtPersonDataType newEntry) { // create node ExtPersonType* temp = new ExtPersonType(new Entry); temp->next = NULL; if(head==NULL) { // empty list becomes the new node head = temp; return; } else { // link the new node tail->next = temp; } } };
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.