//----------------------------------------------------------------------
//  IMPLEMENTATION FILE (pen.cpp)
//  This module exports a Color type, a WriteColor function, and
//  a Pen class (derived from the Supply class).
//----------------------------------------------------------------------
#include "pen.h"
#include <iostream.h>

void WriteColor( Color c )
    //..................................................................
    // PRE:  Assigned(c)
    // POST: Value of c displayed as a character string
    //..................................................................
{
    switch (c) {
        case red:   cout << "red";    break;
        case green: cout << "green";  break;
        case blue:  cout << "blue";   break;
        case NA:    cout << "NA";     break;
    }
}

// Additional private members of Pen class:
//    Color pColor;
//    Color iColor;

Pen::Pen( /* in */ const char* description,
          /* in */ int         stockNumber,
          /* in */ int         initQuantity,
          /* in */ float       initPrice,
          /* in */ Color       penColor,
          /* in */ Color       inkColor     )
    : Supply(description, stockNumber, initQuantity, initPrice)
    //..................................................................
    // PRE:  All parameters assigned
    // POST: New object created via implicit call to base class
    //       constructor (passing the 4 required parameters to
    //       that constructor)
    //    && pColor == penColor  &&  iColor == inkColor
    //..................................................................
{
    pColor = penColor;
    iColor = inkColor;
}

Pen::Pen( const Pen& otherPen ) : Supply(otherPen)
    //..................................................................
    // POST: New object created via implicit call to base class
    //       copy-constructor (passing otherPen as a parameter to
    //       base class's copy-constructor)
    //    && pColor == otherPen.pColor  &&  iColor == otherPen.iColor
    //..................................................................
{
    pColor = otherPen.pColor;
    iColor = otherPen.iColor;
}

Pen::~Pen()
    //..................................................................
    // POST: Object destroyed via implicit call to
    //       base class destructor
    //..................................................................
{
    // Nothing to do before base class destructor called
}

void Pen::Display() const
    //..................................................................
    // POST: After base class's version of Display() invoked,
    //       pen and ink color have been written to standard output
    //..................................................................
{
    Supply::Display();
    cout << "     Pen: ";
    WriteColor(pColor);
    cout << "  Ink: ";
    WriteColor(iColor);
    cout << '\n';
}


