Extraignment02
Home ] Up ]

 

CSIS 250 2002 Spring

Extraignment 02

Date Assigned: 04/17/2002

Date Due: 04/26/2002

 Overload the following operators/functions for the CAddress class as members in the program caddress04.cpp:

 

bool CAddress::operator ==(CAddress &a2) const 

For equality of two addresses

bool CAddress::operator !=(CAddress &a2) const 

For inequality of two addresses

For each operator/function, include detailed documentation and properly indented source code.

Submit the following:

§         Printed source code of the working program (to get any credit the function has to work)

§         Printed output

§         Self-evaluation table

Your Name:

 

Self-evaluation Table for CSIS 250 Extraignment 02

 

 

Max Score

Score

==

Name

1

 

Description

1

 

Examples

1

 

Algorithm

1

 

Prototype

1

 

Returns

1

 

Parameters

1

 

Shared external names

1

 

Local variables used

1

 

Source code

1

 

Properly indented source code

5

 

Output from 10 cases

10

 

!=

Name

1

 

Description

1

 

Examples

1

 

Algorithm

1

 

Prototype

1

 

Returns

1

 

Parameters

1

 

Shared external names

1

 

Local variables used

1

 

Source code

1

 

Properly indented source code

5

 

Output from cases

10

 

Total Score

50

 

 

The two test driver functions should be as follows:

void testCAddressOperatorNotEqual(void)

  {

  cout << "testCAddressOperatorNotEqual\n";

  cout << "============================\n";

  for (int i=1; i<=TEST_COUNT; i++)

    {

    CAddress a1('r'), a2('r');

    cout << "a1=\n";

    cout << a1 << endl;

    cout << "a2=\n";

    cout << a2 << endl;

    if(a1 != a2)

      cout << "a1 and a2 are not equal\n";

    else

      cout << "a1 and a2 are equal\n";

 

    a1 = a2;

    cout << "After a1 = a2;\n";

    cout << "a1=\n";

    cout << a1 << endl;

    cout << "a2=\n";

    cout << a2 << endl;

    if(a1 != a2)

      cout << "a1 and a2 are not equal\n";

    else

      cout << "a1 and a2 are equal\n";

    cout << "-------------------------\n";

    }

  }

 

 

void testCAddressOperatorEqual(void)

  {

  cout << "testCAddressOperatorEqual\n";

  cout << "=========================\n";

  for (int i=1; i<=TEST_COUNT; i++)

    {

    CAddress a1('r'), a2('r');

    cout << "a1=\n";

    cout << a1 << endl;

    cout << "a2=\n";

    cout << a2 << endl;

    if(a1 == a2)

      cout << "a1 and a2 are equal\n";

    else

      cout << "a1 and a2 are not equal\n";

 

    a1 = a2;

    cout << "After a1 = a2;\n";

    cout << "a1=\n";

    cout << a1 << endl;

    cout << "a2=\n";

    cout << a2 << endl;

    if(a1 == a2)

      cout << "a1 and a2 are equal\n";

    else

      cout << "a1 and a2 are not equal\n";

 

    cout << "-------------------------\n";

    }

  }

The output from the program should be similar to the following:

testCAddressOperatorEqual

=========================

a1=

First Name: Dan

 Last Name: Rather

    Street: 34 Rouse Dr

      City: Joplin

     State: MO

       Zip: 62123

       Age: 24

 

a2=

First Name: Bob

 Last Name: Smith

    Street: 12 Joplin St

      City: Neosho

     State: AR

       Zip: 62123

       Age: 40

 

a1 and a2 are not equal

After a1 = a2;

a1=

First Name: Bob

 Last Name: Smith

    Street: 12 Joplin St

      City: Neosho

     State: AR

       Zip: 62123

       Age: 40

 

a2=

First Name: Bob

 Last Name: Smith

    Street: 12 Joplin St

      City: Neosho

     State: AR

       Zip: 62123

       Age: 40

 

a1 and a2 are equal

-------------------------

testCAddressOperatorNotEqual

============================

a1=

First Name: Joe

 Last Name: Ray

    Street: 23 Broadway

      City: Parsons

     State: MO

       Zip: 66921

       Age: 21

 

a2=

First Name: Bob

 Last Name: Letterman

    Street: 23 Broadway

      City: Miami

     State: TX

       Zip: 62123

       Age: 39

 

a1 and a2 are not equal

After a1 = a2;

a1=

First Name: Bob

 Last Name: Letterman

    Street: 23 Broadway

      City: Miami

     State: TX

       Zip: 62123

       Age: 39

 

a2=

First Name: Bob

 Last Name: Letterman

    Street: 23 Broadway

      City: Miami

     State: TX

       Zip: 62123

       Age: 39

 

a1 and a2 are equal

-------------------------