smallPointExample[1]

smallPointExample[1] - -p2 getx double Line:intercept...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <iostream> using namespace std ; class Point{ private : double x ; double y ; public : Point( void ); Point( double , double ); double getx(); double gety(); void input( double , double ); }; Point :: Point (){ x= 0 ; y= 0 ; } Point :: Point ( double x1, double y1){ x=x1; y=y1; } double Point ::getx(){ return x; } double Point ::gety(){ return y; } void Point ::input( double x1, double y1){ x=x1; y=y1; } class Line{ private : Point p ; double s ; public : Line( Point , double ); Line( Point , Point ); double getx( double ); double gety( double ); double intercept(); bool isOntheLine( Point ); }; Line :: Line ( Point p1, double s1){ p=p1; s=s1; } Line :: Line ( Point p1, Point p2){
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
p=p1; s=(p1. gety ()-p2. gety ())/(p1. getx
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ()-p2. getx ()); } double Line ::intercept(){ return p. gety ()-s*p. getx (); } bool Line ::isOntheLine( Point p1){ if (p1. gety ()==s*p1. getx ()+ intercept ()) return true ; else return false ; } int main(){ double x,y; Point p[ 3 ]; for ( int i= ;i< 3 ;i++){ cout << "Give x coordinate for point #" << i+ 1 << ": " ; cin >> x; cout << "Give y coordinate for point #" << i+ 1 << ": " ; cin >> y; p[i]. input (x,y); } Line a(p[ ],p[ 1 ]); if (a. isOntheLine (p[ 2 ])) cout << "Point is on the line!" ; else cout << "Point is NOT on the line!" ; return ; }...
View Full Document

This note was uploaded on 09/27/2011 for the course CGS 2421 taught by Professor Onal during the Spring '09 term at University of Florida.

Page1 / 2

smallPointExample[1] - -p2 getx double Line:intercept...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online