#ifndef CXX_COURSE_RAY_H
#define CXX_COURSE_RAY_H

// include the header necessary for input/output
#include <iostream.h>
#include "ratpoint.h"
#include "rational.h"
#include "line.h"

// class declaration begins here
class ray
{
  public:
    // constructors and destructor 
    ray ();
    ray ( const ray & x );
    ray ( const ratpoint & rp1 , const ratpoint & rp2 ) ;
    ~ray ( );

    // accessors
    bool vert ( ) const { return myline.vert(); }
    rational slope () const { return myline.slope(); }
    rational xcept () const { return myline.xcept(); }
    line ln () const { return myline; }
    ratpoint startpt () const { return mystartpt; }
    bool dir () const { return mydir; }

    void makeray ( const ratpoint & rp1, const ratpoint & rp2 );
    
    // other functions
    bool hitpoint ( const ratpoint & x ); // ray goes through this point?
    bool intersect ( ray & x ); // ray intersects other ray @ 1point?
    bool intersect ( line & x ); // ray intersects other ray @ 1point?
    ratpoint intersection ( ray & x ); // What is intersection?
    ratpoint intersection ( line & x ); // What is intersection?
    void reverse ( void ) ; // reverse direction of ray

    // overloading of the assignment operator =
    ray & operator = ( const ray & x );

    // overloading of the input and output operator
    friend ostream & operator << ( ostream & out , const ray & x);

  private:
    line myline;
    ratpoint mystartpt;
    bool mydir; 

    // error handling routine
    static void error ( char *text )
      {
        cerr << "ray error: " << text << endl;
        exit(1);
      }

};
// class declaration ends here

#endif


