#ifndef CXX_COURSE_LINE_H
#define CXX_COURSE_LINE_H

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

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

    // accessors
    bool vert ( ) const { return is_vertical; }
    rational slope () const { return myslope; }
    ratpoint point1 () const { return end1; }
    ratpoint point2 () const { return end2; }

    void makeline ( const ratpoint & rp1, const ratpoint & rp2 );
    
    // other functions
    bool hitpoint ( const ratpoint & x ); // line goes through this point?
    bool intersect ( const line & x );
    ratpoint intersection ( const line & x );
    int side ( const ratpoint & x );
      // returns: 0 if point is outside of end1, 1 if between, 2 if 
      // outside end2
    bool between ( const ratpoint & x , const ratpoint & y , 
		     const ratpoint & z );
      // returns true if x is between y and z.  (all are assumed on the line;
      // I don't check for this!)

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

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

  private:
    bool is_vertical;
    rational myslope;
    ratpoint end1;
    ratpoint end2;

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

};
// class declaration ends here

#endif


