// receiver.cc
// Class member function definition file 

#include <iostream>
#include <cstring> // for strlen and strcpy
using namespace std;

#include "receiver.h"


// constructor for the class Receiver_C
// the return type of constuctor is "NOTHING"
// not void, not int, not Receiver_C, but "NOTHING"

Receiver_C::Receiver_C(
	     const char * const aName, 
             const char * const aTeam, 
	     const int howManyCatches, 
             const double theYACValue)
{
  name = new char [strlen(aName) + 1 ];
  strcpy(name, aName);

  team = new char [strlen(aTeam) + 1 ];
  strcpy(team, aTeam);

  setCatches(howManyCatches);

  YAC = theYACValue;

}


// set function for the data member "catches"

void Receiver_C::setCatches(int howManyCatches)
{
  if (howManyCatches < 0)
    {
      cerr << "Error: Illegal value in setCatches function: "
	   << howManyCatches << endl;
      cerr << "Error was caught at line " << __LINE__ 
	   << " in file " << __FILE__ << endl;
      exit(1);

    }
  
  catches = howManyCatches;
}


// the double colon is called the
//   binary scope resolution operator

void Receiver_C::print()
{
  cout << "name     : " << name << endl;
  cout << "team     : " << team << endl;
  cout << "catches  : " << catches << endl;
  cout << "YAC      : " << YAC << endl;
}

