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
{ 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
{ 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
using namespace std;
#include "ListArray.cpp"
template < typename DataType, typename KeyType > class OrderedList : public List
public: bool binarySearch ( KeyType searchKey, int &index ); using List
#endif // #ifndef ORDEREDLIST_H
OrderedList.cpp
#include "OrderedList.h"
template < typename DataType, typename KeyType > OrderedList
template < typename DataType, typename KeyType > void OrderedList
template < typename DataType, typename KeyType > void OrderedList
template < typename DataType, typename KeyType > bool OrderedList
template < typename DataType, typename KeyType > void OrderedList
template < typename DataType, typename KeyType > bool OrderedList
#include "show4.cpp"
packet.cpp
#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
// 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
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
Get step-by-step solutions from verified subject matter experts
