previous | start | next

InvoiceTest

Here is a sample invoice test program:

int main()
{
  Address ezAddr("EZ Rental",
           "8384 Dempsey",
           "Brooklyn",
           "NY",
           "01234");

  Invoice ezInv(ezAddr, 10);

  ezInv.add(Product("Power Cleaner", 49.95), 1);
  ezInv.add(Product("PX Cleaner Fluid", 9.00), 8);
  ezInv.add(Product("M803 Vac Bags", 2.08), 10);

  cout << ezInv.format() << endl;
  
  return 0;
}

The responsibilities for formatting and printing the invoice are distributed over the classes as a result of the design phase. No one class has to do everything and so each class can be easier to understand and implement.

In general, this CRC technique can provide an effective way of modularizing a program using object oriented features. Classes are designed and Responsibilities are assigned to the chosen class objects with the goal of building a system according to specified requirements.



previous | start | next