"Close but no cigar" This code does everything great until the end where for many days I have been trying to maintain the current outputs but somehow add a display where WorTN q and Tnum x print together followed by WorTN q, Tnum x and BTN s printing together. Also, where WorTN r and Tnum y print together followed by WorTN r, Tnum y and BTN t printing together. Something like:
Customer: Security
Telephone no#: (312)777-1111
Customer: Security
Telephone no#: (312)777-1111
No# phone lines: 10
_______________ _______________ _____
Customer: Library
Telephone no#: (312)444-2222
Customer: Library
Telephone no#: (312)444-2222
No# phone lines: 8
Any solution i.e... pointers etc. would be better than not getting 'er' done. Please advise. Thanks ~LS
Customer: Security
Telephone no#: (312)777-1111
Customer: Security
Telephone no#: (312)777-1111
No# phone lines: 10
_______________ _______________ _____
Customer: Library
Telephone no#: (312)444-2222
Customer: Library
Telephone no#: (312)444-2222
No# phone lines: 8
Any solution i.e... pointers etc. would be better than not getting 'er' done. Please advise. Thanks ~LS
Code:
// W I P_2 //Tnum.h interface
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
class Tnum {
public:
string NPA, NXX, LINE, P_NUM;
Tnum( ) {cout <<"\n Tnum default constructor proof\n";}
Tnum( string a,string b,string c );
void ph_num( );
~Tnum( );
string GetNPA( ) const { return NPA; }
void SetNPA( string g ) { NPA = g; }
string GetNXX( ) const { return NXX; }
void SetNXX( string h ) { NXX = h; }
string GetLINE( ) const { return LINE; }
void SetLINE( string i ) { LINE = i; }
};
Tnum::Tnum( string a,string b,string c ) {
NPA = a;
NXX = b;
LINE = c;
P_NUM = NPA + NXX + LINE; }
void Tnum::ph_num( ) {
cout <<" \n Tnum parameterized constructor proof\n\n Type 3 digit area code then press 'ENTER' key ";
cin >> NPA;
cout <<" \n Type 3 digit prefix then press 'ENTER' key ";
cin >> NXX;
cout <<" \n Type 4 digit line number then press 'ENTER' key ";
cin >> LINE;
P_NUM = NPA + NXX + LINE; cout <<" \n Telephone no#: "<< P_NUM <<"\n"; }
Tnum::~Tnum( ) {
cout <<" \n Tnum destructor fx flushed object containing variable value "<< P_NUM <<"\n\n_________________________________________________________________________"<<endl;}
//________________________________________________
//WorTN.h interface
class WorTN : public Tnum {
public:
string CustName;
WorTN( ) {cout <<"\n WorTN default constructor proof\n";}
WorTN( string d );
void cust_num( );
~WorTN( );
string GetCustName( ) const { return CustName; }
void SetCustName( string j ) { CustName = j; }
};
WorTN::WorTN( string d ) { CustName = d; }
void WorTN::cust_num( ) {
cout << " \n WorTN parameterized constructor proof\n\n Type customer name then press 'ENTER' key ";
cin >> CustName; cout <<" \n Customer name: "<< CustName <<endl; }
WorTN::~WorTN( ) {
cout <<" \n WorTN destructor fx flushed object containing variable value "<< CustName <<"\n\n_________________________________________________________________________"<<endl;}
//____________________________________________________________________________
//BTN.h interface
class BTN : public WorTN {
public:
int NumWrkLines;
BTN( ) {cout <<"\n BTN default constructor proof\n";}
BTN( int e );
void cust_num_lines( );
~BTN( );
int GetNumWrkLines( ) const { return NumWrkLines; }
void SetNumWrkLines( int k ) { NumWrkLines = k; }
};
BTN::BTN( int e ) { NumWrkLines = e; }
void BTN::cust_num_lines( ) {
cout << " \n BTN parameterized constructor proof\n\n Type number of lines then press 'ENTER' key ";
cin >> NumWrkLines;
cout <<" \n No# of lines: "<< NumWrkLines <<endl; }
BTN::~BTN( ) {
cout <<" \n BTN destructor fx flushed object containing variable value "<< NumWrkLines <<"\n\n_________________________________________________________________________"<<endl;}
//___________________________________________________________________________________
//Tnum_main.cpp utilization
ostream &operator<<(ostream &print1, Tnum m) {
print1 << "\n Telephone no#: (" << m.NPA << ") ";
print1 << m.NXX << "-" << m.LINE << "\n";
return print1; }
ostream &operator<<(ostream &print2, WorTN n) {
print2 << "\n Customer: "<< n.CustName << "\n";
return print2; }
ostream &operator<<(ostream &print3, BTN o) {
print3 << "\n No# phone lines: "<< o.NumWrkLines << "\n";
return print3; }
ostream& T( ostream& p ) { return p <<'\a'; }
int main( ) {
Tnum xx; xx.ph_num( ); xx.~Tnum( );
WorTN yy; yy.cust_num( ); yy.~WorTN( );
BTN zz; zz.cust_num_lines( ); zz.~BTN( );
Tnum x( "(312) ","777-","1111" );
Tnum y( "(312) ","444-","2222" );
cout << x << y <<T<<T<<T<<T<<"\n__________________________\n";
WorTN q( "Security" );
WorTN r( "Library" );
cout << q << r <<T<<T<<T<<T<<"\n__________________________\n";
BTN s( 10 );
BTN t( 8 );
cout << s << t <<T<<T<<T<<T<<"\n__________________________\n";
system ("pause");
return 0;
}
Comment