#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 isvert; }
    rational slope () const { return myslope; }
    rational xcept () const { return myxcept; }

    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 ); // line intersects other line @1point?
    ratpoint intersection ( const line & x ); // What is intersection?

    // 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 isvert;         // Is the line vertical?
    rational myslope;    // slope, if not vertical
    rational myxcept;    // x-intercept if not vert, y-intercept otherwise

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

};
// class declaration ends here

#endif


