Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

///MemberDO.h #ifndef MEMBERDO #define MEBERDO #include LinkedList.h #include class MemberDO { private: int key; std::string lastName; char firstInit; double dues; public: MemberDO(); MemberDO(int, std::string, char,

///MemberDO.h

#ifndef MEMBERDO #define MEBERDO

#include "LinkedList.h" #include

class MemberDO { private: int key; std::string lastName; char firstInit; double dues; public: MemberDO(); MemberDO(int, std::string, char, double);

int getKey() const; void setKey(int); std::string getLastName() const; void setLastName(std::string); char getFirstInitial() const; void setFirstInitial(char); double getDues() const; void setDues(double); void print() const;

static void readFromFile(const char*, OrderedLinkedList&); };

#endif

//MemberDO.cpp

#include "MemberDO.h" #include #include

using namespace std;

MemberDO::MemberDO() { }

MemberDO::MemberDO(int k, string ln, char fi, double d) { }

int MemberDO::getKey() const { return 0; }

void MemberDO::setKey(int k) { }

string MemberDO::getLastName() const { return ""; }

void MemberDO::setLastName(string ln) { }

char MemberDO::getFirstInitial() const { return 0; }

void MemberDO::setFirstInitial(char fi) { }

double MemberDO::getDues() const { return 0; }

void MemberDO::setDues(double d) { }

void MemberDO::print() const { }

void MemberDO::readFromFile(const char* file, OrderedLinkedList& ll) {

//Delete the following implementation and replace with an implemenation that actually reads the data from the file for extra credit. MemberDO data; data.key = 6789; data.lastName = "Towson"; data.firstInit = 'J'; data.dues = 65.25; ll.insert(data); data.key = 3456; data.lastName = "Johns"; data.firstInit = 'K'; data.dues = 200.00; ll.insert(data); data.key = 1123; data.lastName = "Stevens"; data.firstInit = 'M'; data.dues = 112.35; ll.insert(data); data.key = 4489; data.lastName = "Ellwood"; data.firstInit = 'B'; data.dues = 700.25; ll.insert(data); data.key = 5555; data.lastName = "Pryor"; data.firstInit = 'R'; data.dues = 99.99; ll.insert(data); }

//LinkedList.h

#ifndef ORDEREDLINKEDLIST_H #define ORDEREDLINKEDLIST_H

template struct Node { Type info; Node *next; };

template class OrderedLinkedList { public: OrderedLinkedList(); OrderedLinkedList(const OrderedLinkedList& other); ~OrderedLinkedList(); OrderedLinkedList& operator=(const OrderedLinkedList& other); int insert(const Type&); Type* find(int) const; Type* get(int) const; int remove(int); void clear(); int size() const; void print() const; };

template OrderedLinkedList::OrderedLinkedList() { }

template OrderedLinkedList::OrderedLinkedList(const OrderedLinkedList& other) { }

template OrderedLinkedList::~OrderedLinkedList() { }

template OrderedLinkedList& OrderedLinkedList::operator=(const OrderedLinkedList& other) { return *this; }

template int OrderedLinkedList::insert(const Type& item) { return -1; }

template Type* OrderedLinkedList::get(int dest) const { return nullptr; }

template Type* OrderedLinkedList::find(int dest) const { return nullptr; }

template int OrderedLinkedList::remove(int key) { return 0; }

template void OrderedLinkedList::clear() { }

template int OrderedLinkedList::size() const { return -1; }

template void OrderedLinkedList::print() const { } #endif

//LinkedListTest.cpp

(please see subsequent posted question by me where i will post LinkedListTest.cpp codes)

readme.md file

Club Membership Linked List

A registry of club members can be created in the form of an ordered linked list of Member data objects. Each Member object is an element or node in the linked list. The information for each Member includes an Identification Number, Last Name, First Initial, and Yearly Dues.

The data for five existing club members are contained in a file named Member.dat. You will write a program that implements a generic ordered linked list, creates an instance of this list that contains Member objects, reads existing member data from Member.dat , inserts members into the list, and removes members from the list.

The program must satisfy all test statements contained in the associated starter file.

Goals:

The purpose of this project is to continue working with C++ classes, practice working with templates, and understand and implement the concepts of a linked list data structure.

Requirements:

Code construction can be divided into two primary tasks:

1. MemberDO class

Create a data object class named MemberDO that represents the data for a club member. The names of the data members and the associated data types are as follows:

int key; string lastName; char firstInitial; double dues; 

The key represents the unique ID number of the club member and will be used exclusively to locate nodes in the implementation of the linked list methods.

The following methods should be implemented for the MemberDO class:

  1. Default constructor.
  2. Four-argument constructor that initializes each data member to a specific value passed as a parameter to this method.
  3. Appropriate getter and setter methods. The getter methods should have names that correspond with the calls used in the test code contained in the starter file.
  4. A static method named readFromFile that takes a C-string as the first parameter, and an orderedLinkedList object as the second parameter. The first argument is the filename that contains data for existing members. This method should read the data for each individual member from the input file (one line of data per member), create a new MemberDO object, and insert this object into the linked list specified in the second argument. Implelmenting this method is extra-credit. You can use the implementation provided which just inserts the data without reading it from a file if you do not want the extra credit.

2. orderedLinkedList class

Create a generic ordered linked list class named orderedLinkedList using template syntax. The linked list should have at mostthree private data members:

  1. a pointer to the first node in the list
  2. a pointer to the last node in the list
  3. a count of the number of nodes in the list

The orderedLinkedList should implement the following methods and satisfy each of the associated specifications as given here:

// default constructor // initializes the list to an empty state // Postcondition: first = NULL, last = NULL, count = 0; orderedLinkedList(); // Function to insert newItem in the ordered list // Key values should be used exclusively to find appropriate // location for inserted object // Postcondition: first points to the new list, newItem // is inserted at the proper place in the list, and // count is incremented by 1 // Return: Key value of item inserted on the list int insert(const Type& newItem); // Function to get the object at a specific location on the list // For example, if location = 0, find the first item on the list // If location = 4, find the fifth item on the list // Postcondition: Status of list not changed // Return: Object if found, NULL if object not found or if // location value is <= 0. Type \* get(int location) const; // Function to find the object by key in the list // For example, find the item with key=1123 in the list // Postcondition: Status of list not changed // Return: Object if found, NULL if object not found Type \* find(int key) const; // Function to remove an item with key == keyValue from the list // Key values should be used exclusively to identify // object to be removed // Postcondition: if found the node with key == keyValue is // removed from the list; // first points to the first node of the new list; count is // decremented by 1. // Return: If item is in list, return key, else return -1. int remove(int keyValue); 

As noted in the above specifications, the ordered linked list methods should be implemented such that node identification is accomplished using only key comparisons.

readme.md file end

consists of 4 files: LinkedList.h, MemberDO.h, MemberDO.cpp, LinkedListTest.cpp (this has 146 lines of codes, was unable to post this as it says question too long, (please see the subsequent question posted by me where I will post LinkedListTest.cpp codes) and readme file has all the required instructions

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Murach's SQL Server 2012 For Developers

Authors: Bryan Syverson, Joel Murach, Mike Murach

1st Edition

1890774693, 9781890774691

More Books

Students also viewed these Databases questions