
#ifdef GNU
#include <iostream.h>
#define std
#else
#include <iostream>
#endif

#include "student.h"


const std::string NULL_STRING = "";

/////////////////////////////////////////////////////////////////
//
//    StudentRecord  member functions
//
//   These are straightforward.  

StudentRecord::StudentRecord( ) 
  : user_id_(NULL_STRING), year_(NULL_STRING), ssn_(NULL_STRING),
    tuition_paid_(0), credits_earned_(0), grade_points_(0)
{
}


StudentRecord::StudentRecord( const std::string &id_in,
			      const std::string &cl_in,
			      const std::string &ssn_in,
			      float tuition_in,
			      int credits_in,
			      float g_pts_in )
  : user_id_(id_in), year_(cl_in), ssn_(ssn_in),
    tuition_paid_(tuition_in), credits_earned_(credits_in), 
    grade_points_(g_pts_in)
{
}


void
StudentRecord::pay( float amount )
{
  tuition_paid_ += amount;
}


void
StudentRecord::add_grades( int credits, float grade_sum )
{
  credits_earned_ += credits;
  grade_points_ += grade_sum;
}


float
StudentRecord::gpa( ) const
{
  if ( credits_earned_ == 0.0 ) {
    return 0.0;
  }
  else {
    return grade_points_ / credits_earned_;
  }
}


std::ostream &
operator << ( std::ostream & outstr,
	      const StudentRecord & student )
{
  outstr << "     computer id:  " << student.user_id_ << "\n"
         << "            year:  " << student.year_ << "\n"
         << "             ssn:  " << student.ssn_ << "\n"
         << "    tuition paid:  " << student.tuition_paid_ << "\n"
         << "  credits_earned:  " << student.credits_earned_ << "\n"
         << "             gpa:  " << student.gpa() << "\n";
  return outstr;
}

