Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- using namespace std;
- class Point
- {
- private:
- double x;
- double y;
- public:
- Point();
- Point(double first, double second);
- double getX();
- double getY();
- void display();
- ~Point();
- };
- Point::Point(void)
- {
- x = 0.0;
- y = 0.0;
- }
- Point::Point(double first, double second)
- {
- x = first;
- y = second;
- }
- Point::~Point(void)
- {
- }
- double Point::getX(void)
- {
- return x;
- }
- double Point::getY(void)
- {
- return y;
- }
- void Point::display()
- {
- cout << "(" << x << ", " << y << ")" << endl;
- }
- class Line
- {
- private:
- double offset, slope;
- public:
- Line();
- Line(Point P1, Point P2);
- bool isPerpendicularTo(Line l);
- void display();
- ~Line();
- };
- Line::Line(void)
- {
- offset = 0.0;
- slope = 1.0;
- }
- Line::Line(Point p1, Point p2)
- {
- }
- void Line::display()
- {
- cout << "y = " << slope << "x + " << offset << endl;
- }
- ///If multiplication of 2slope of 2line equal to -1
- bool isPerpendicularTo(Line l)
- {
- }
- int main()
- {
- Point P1(1.0, 2.0), P2(3.0, -3.0), P3(0.0,1.0), P4(10.0, 5.0);
- Line L1(P1, P2);
- L1.display();
- cout << endl;
- Line L2(P3, P4);
- L2.display();
- cout << endl;
- if(L1.isPerpendicularTo(L2)){
- cout << "Line ";
- L1.display();
- cout << " is perpendicular to Line ";
- L2.display();
- cout << "." << endl;
- }
- else{
- cout << "Line ";
- L1.display();
- cout << " is NOT perpendicular to Line ";
- L2.display();
- cout << "." << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement