Question: PLEASE COMPLETE THE FOLLOWING IN C++ - OrderedList.cpp - lab04-ex1.cpp - packet.cpp show3.cpp #include ListArray.h #define ORDEREDLIST_CPP 1 template void List :: showStructure () const

PLEASE COMPLETE THE FOLLOWING IN C++

- OrderedList.cpp

- lab04-ex1.cpp

- packet.cpp

show3.cpp

#include "ListArray.h"

#define ORDEREDLIST_CPP 1

template void List:: showStructure () const

{ int j;

if ( size == 0 ) cout << "empty list" << endl; else { cout << "size = " << size << " cursor = " << cursor << endl; for ( j = 0 ; j < maxSize ; j++ ) cout << j << "\t"; cout << endl; for ( j = 0 ; j < size ; j++ ) { if( j == cursor ) { cout << "["; cout << dataItems[j] #ifdef ORDEREDLIST_CPP .getKey() #endif ; cout << "]"; cout << "\t"; } else cout << dataItems[j] #ifdef ORDEREDLIST_CPP .getKey() #endif << "\t"; } cout << endl; } }

show4.cpp

#include "OrderedList.h"

template < typename DataType, typename KeyType > void OrderedList:: showStructure () const

{ if ( size == 0 ) cout << "Empty list" << endl; else { cout << "size = " << size << " cursor = " << cursor << endl; for ( int j = 0 ; j < maxSize ; ++j ) cout << j << "\t"; cout << endl; for ( int j = 0 ; j < size ; ++j ) { if( j == cursor ) { cout << "[" << dataItems[j].getKey() << "]\t"; } else { cout << dataItems[j].getKey() << "\t"; } } cout << endl; } }

OrderedList.h

#ifndef ORDEREDLIST_H #define ORDEREDLIST_H

#include #include

using namespace std;

#include "ListArray.cpp"

template < typename DataType, typename KeyType > class OrderedList : public List { public: static const int DEFAULT_MAX_LIST_SIZE = 10; OrderedList ( int maxNumber = DEFAULT_MAX_LIST_SIZE ); virtual void insert ( const DataType &newDataItem ) throw ( logic_error ); virtual void replace ( const DataType &newDataItem ) throw ( logic_error ); bool retrieve ( const KeyType& searchKey, DataType &searchDataItem ); void showStructure () const; void merge ( const OrderedList &other ) throw ( logic_error ); bool isSubset ( const OrderedList &other );

public: bool binarySearch ( KeyType searchKey, int &index ); using List::remove; using List::clear; using List::isEmpty; using List::isFull; using List::gotoBeginning; using List::gotoEnd; using List::gotoNext; using List::gotoPrior; using List::maxSize; using List::cursor; using List::size; using List::dataItems; };

#endif // #ifndef ORDEREDLIST_H

OrderedList.cpp

#include "OrderedList.h"

template < typename DataType, typename KeyType > OrderedList::OrderedList ( int maxNumber ) { }

template < typename DataType, typename KeyType > void OrderedList::insert ( const DataType &newDataItem ) throw ( logic_error ) { }

template < typename DataType, typename KeyType > void OrderedList::replace ( const DataType &newDataItem ) throw ( logic_error ) { }

template < typename DataType, typename KeyType > bool OrderedList::retrieve ( const KeyType& searchKey, DataType &searchDataItem ) { return false; }

template < typename DataType, typename KeyType > void OrderedList::merge ( const OrderedList &other ) throw ( logic_error ) { }

template < typename DataType, typename KeyType > bool OrderedList::isSubset ( const OrderedList &other ) { return false; }

#include "show4.cpp"

packet.cpp

#include #include

using namespace std;

#include "OrderedList.cpp"

class Packet { public: static const int PACKET_SIZE = 6; // Number of characters in a packet // including null ('\0') terminator, // but excluding the key (1st char in each line). int position; // (Key) Packet's position w/in message char body[PACKET_SIZE]; // Characters in the packet

int getKey() const { return position; } // Returns the key field };

int main() { ifstream messageFile("message.dat"); // Message file OrderedList message; // Message Packet currPacket; // Message packet int j; // Loop variable

// Read in the packets

// Output the message packet-by-packet.

return 0; }

lab04-ex1.cpp

#include

#include "OrderedList.cpp"

using namespace std;

class Account { public: int accountNum; // (Key) Account number float balance; // Account balance int getKey () const { return accountNum; } // Returns the key };

int main() { OrderedList accounts(20); // List of accounts Account acct; // A single account // Read in information on a set of accounts.

cout << endl << "Enter account number and balance (EOF to end) : "; while ( cin >> acct.accountNum >> acct.balance ) { accounts.insert(acct); cout << "Enter account number and balance (EOF to end) : "; }

// Output the accounts in ascending order based on their account // numbers. cout << endl; if ( !accounts.isEmpty() ) { accounts.gotoBeginning(); do { acct = accounts.getCursor(); cout << acct.accountNum << " " << acct.balance << endl; } while ( accounts.gotoNext() ); }

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!