Explore BrainMass
Share

List Program C++ with multiple operations

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

You are to implement a 'List' class to handle a list with general operations. That means you can insert and delete any element anywhere in the list. The list has no order, except for the order you insert or delete. The methods you are to implement are as given:

Constructor methods (two, default and copy constructor, a list to a newly defined list, i.e. 'List listA(listB)'):

Empty returns true or false if list is empty or not.
Front makes current position at the beginning of the list.
End makes current position at the end of a list.
Previous places current position at the previous element in the list.
Next places current position at the next element in the list.
Get position returns current position or where you are in the list.
Set position (int) places current position in a certain position in the list.
Insert before inserts as a new element before the current position.
Insert after inserts as a new element after the current position.
Get element returns the one element that current position is pointing to.
Size returns the size of the list (number of elements in list).
Replace (int) replace the current element with a new value.
Erase deletes the current element.
Clear makes the list an empty list.
Reverse reverses elements in a list.
Swap swaps all the elemments of one list with the another list.

Overload the operators: (at least) << output, == , + , = (assignment)

You are to implement the List class using an array. For now the array can be 20 in size.
You will need to use the 'ElementType' for 'typing' your data.
You will need to use CAPACITY constant for the size of the array, in case we need to change the array size.
When adding two lists make sure its within capacity, otherwise ignore it.
When printing out the array across the screen horizontally, print only values that have been inserted, not all zeros.

Please see the attachement as well.

© BrainMass Inc. brainmass.com October 25, 2018, 7:22 am ad1c9bdddf
https://brainmass.com/computer-science/c/list-program-c-multiple-operations-501251

Attachments

Solution Summary

The solution contains an List.h with C++ list implementation and a ListMain.cpp testing program that calls list methods. The list requested is implemented using an array.

$2.19
See Also This Related BrainMass Solution

Design an address book application to keep track of the names, addresses, phone numbers, and birthdays of family, friends, and colleagues.

Design an address book application to keep track of the names, addresses, phone numbers, and birthdays of family, friends, and colleagues. You may implement your own linked list library, but it is recommended that you make use of the linked list API in the C++ standard template library.

At a minimum, your program should implement at least one object called AddressRecord and should hold the following data:

* recordId (must be an int. This field uniquely identifies a record in your address book)
* firstName
* lastName
* contactType (i.e. friend, family, etc.)
* streetAddress
* city
* state
* zipCode

Provide the appropriate accessor methods to set and get the data. The main program must provide the following functionality.

1. When the program is first started, it should read a data file "address.dat", if it exists, and load the data from this file in the address book&#8217;s linked list.

2. When the program exits, it should save all of the entries in the address book linked list into the "address.dat" data file. At this point, if this file does not exist, the program should create it.

3. Provide a text-based user interface to allow the user to operate on the address book data. The program should allow the user to:
(a) view all entries in the address book;
(b) search for an entry in the address book by last name (if the entry exists, print the record);
(c) add an entry to the address book;
(d) delete an entry from the address book; and
(e) modify any of the data (except the recordId) for given address book entry selected by the user. These operations should work on a linked list that holds all of the entries of the address book.

View Full Posting Details