//  File: colorcube.C
//
//  Implementation of the ColorCube derived class

#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>

#include "colorcube.h"

// Default constructor
// Note: default constructor for Cube is called already.

ColorCube::ColorCube() {
    
#ifndef NDEBUG
   cerr << "Default Color Cube constructor, this = " << this << endl ;
#endif 

   ccolor = red ;
}


// Alternate constructor 
// Note: we use a member initializer to call the alternate cube constructor

ColorCube::ColorCube(float side, color c) 

:  Cube(side)

{
#ifndef NDEBUG
   cerr << "Alternate Color Cube constructor, this = " << this << endl ;
#endif
   if (c >= red && c <= blue) { 
      ccolor = c ;
   } else { /* bad color given */
      ccolor = red ;
   }
}


// Destructor
//
ColorCube::~ColorCube() {

#ifndef NDEBUG
   cerr << "Color Cube destructor, this = " << this << endl ;
#endif
   
   // Do nothing
}


// report vital stats for color cubes
//
void ColorCube::identify() {
    
   cout << "I'm a " ;

   switch(ccolor) {
      case red   : cout << "red" ;   break ;
      case white : cout << "white" ; break ;
      case blue  : cout << "blue" ;  break ;
      default : cout << "strangely colored" ;
   }
   
   cout << " cube. Each side has length=" << length
        << ". Serial number = " << serial() << endl ;
}
