Home > Articles > Programming > C/C++

  • Print
  • + Share This
Like this article? We recommend

Like this article? We recommend

The Third and Last Document Type—a Contract

I want to introduce one more document type—this time a contract illustrated in Listing 6.

Listing 6 Contract Document

class ContractDocument : AnyOldDocument {
public:
  explicit ContractDocument(int Id, char* name, int docType, int number);
  virtual ~ContractDocument();
  const int getPenaltyClauseValue();
  void setPenaltyClauseValue(int number);
};

ContractDocument::ContractDocument(int Id, char* name, int docType, int number)
: AnyOldDocument(Id, name, docType, number)
{
  printf ("Creating a contract document for: %s\n", name);
}

ContractDocument::~ContractDocument() { }

const int ContractDocument::getPenaltyClauseValue()
{
  return GetAssociatedNumber();
}

void ContractDocument::setPenaltyClauseValue(int number)
{
  SetAssociatedNumber(number);
}

Listing 6 is pretty similar to the InvoiceDocument class. The main difference between these two classes is in semantics relating to our old friend: the base class data member called associatedNumber. In the case of InvoiceDocument, this data element represents a price, whereas in the case of the contract class, the associatedNumber element represents a penalty clause value. Penalty clauses are sometimes attached to contracts to act as an incentive for a contractor to complete the work.

  • + Share This
  • 🔖 Save To Your Account