Assignment 06
Home ] Up ]

 

CSIS 250 2002 Spring

Assignment 06

Date Assigned: 04/17/2002

Date Due: 04/26/2002

Add the following member function to CAddress class in program caddress04.cpp:

 

void CAddress::swap(CAddress &a2)  

A function to swap two addresses

For the 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 Project 06

 

 

Max Score

Score

swap

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 calls to swap

10

 

Total Score

25

 

The test driver function should be as follows:

void testCAddressSwap(void)

  {

  cout << "testCAddressSwap\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;

    a1.swap(a2);

    cout << "After CAddress a1.swap(a2);\n";

    cout << "a1=\n";

    cout << a1 << endl;

    cout << "a2=\n";

    cout << a2 << endl;

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

    }

  }

 

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

testCAddressSwap

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

a1=

First Name: Ann

 Last Name: Rather

    Street: 34 Rouse Dr

      City: Joplin

     State: AR

       Zip: 44234

       Age: 56

 

a2=

First Name: Bob

 Last Name: Howard

    Street: 12 Joplin St

      City: Miami

     State: KS

       Zip: 62123

       Age: 20

 

After CAddress a1.swap(a2);

a1=

First Name: Bob

 Last Name: Howard

    Street: 12 Joplin St

      City: Miami

     State: KS

       Zip: 62123

       Age: 20

 

a2=

First Name: Ann

 Last Name: Rather

    Street: 34 Rouse Dr

      City: Joplin

     State: AR

       Zip: 44234

       Age: 56

 

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