Assignment 07
Home ] Up ]

 

CSIS 250 2001 Fall

Assignment 07

Date Assigned:

11/19/2001

Date Due:

11/30/2001

Add the following member functions to the program (Project31.cpp) discussed in the class:

void CInventory::calcDistinctCounts(CInventory &inv, int counts[]) const;

void Cinventory::displayDistinctCounts(const CInventory &inv, int counts[]) const;

The member function calcDistinctCounts determines the distinct records from an inventory object and puts them in alphabetically sorted order and their counts in inv and counts[] respectively.  The member function displayDistinctCounts displays them on the screen.

You should run ten test cases by using the following global test function as it is:

 

void testCalcDistinctCounts(void)

  {

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

    {

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

    cout << "Test Case#:" << i << endl;

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

 

    CInventory originalInv('r'), distinctInv;

    int counts[MAX_ITEMS];

 

    cout << "originalInv =\n";

    cout << originalInv << endl;

    originalInv.calcDistinctCounts(distinctInv, counts);

    cout << "After originalInv.calcDistinctCounts(distinctInv, counts);\n\n";

    cout << "originalInv =\n";

    cout << originalInv << endl;

    cout << “Summary Counts\n”;

    originalInv. displayDistinctCounts(distinctInv, counts);

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

    }

  }

 

 


SAMPLE OUTPUT FROM A TEST RUN

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

Test Case#:5

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

originalInv =

inventory(17)=

[Spoon, 33]

[Stand, 15]

[Phone, 55]

[Mouse, 88]

[Plier, 13]

[Stool, 16]

[Stand, 15]

[Paper, 14]

[Table, 22]

[Clock, 99]

[Knife, 44]

[Couch, 66]

[Mouse, 88]

[Mouse, 88]

[Plier, 13]

[Table, 22]

[Plier, 13]

 

After originalInv.calcDistinctCounts(distinctInv, counts);

 

originalInv =

inventory(17)=

[Spoon, 33]

[Stand, 15]

[Phone, 55]

[Mouse, 88]

[Plier, 13]

[Stool, 16]

[Stand, 15]

[Paper, 14]

[Table, 22]

[Clock, 99]

[Knife, 44]

[Couch, 66]

[Mouse, 88]

[Mouse, 88]

[Plier, 13]

[Table, 22]

[Plier, 13]

 

n  Item

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

1  [Clock, 99]

1  [Couch, 66]

1  [Knife, 44]

3  [Mouse, 88]

1  [Paper, 14]

1  [Phone, 55]

3  [Plier, 13]

1  [Spoon, 33]

2  [Stand, 15]

1  [Stool, 16]

2  [Table, 22]

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

 

Submit the following:

 

1.              Printed source code of only your contribution, not the entire source code (to get any credit the program has to work).

2.              Printed output from ten test cases.

3.              Source code and the executable code on a diskette (name your source as project7.cpp and executable code as project7.exe).

4.              Self-evaluation table.

(Late assignment will not count)

  

Self-evaluation Table for Project 07

Your Name:

 

 

Max Score

Score

calcDistinctCounts

 

Description in your own words

3

 

Initial to final algorithms in pseudo code

7

 

displayDistinctCounts

Description in your own words

5

 

testCalcDistinctCounts

Properly formatted output
(10 cases)

20

 

Total Score

35