ForeverDev

Untitled

Oct 21st, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. class Line {
  7.     public:
  8.         Line(float _x1, float _y1, float _x2, float _y2) {
  9.             x1 = _x1;
  10.             x2 = _x2;
  11.             y1 = _y1;
  12.             y2 = _y2;
  13.             slope = (_y2 - _y1) / (_x2 - _x1);
  14.             length = sqrt(pow(_x2 - _x1, 2) + pow(_y2 - _y1, 2));
  15.         }
  16.         bool parallel(Line& line) {
  17.             return line.slope == slope;
  18.         }
  19.         float slope, length, x1, x2, y1, y2;
  20. };
  21.  
  22. int main() {
  23.     Line one(0, 0, 2, 2);
  24.     Line two(5, 5, 10, 10);
  25.    
  26.     cout << one.parallel(two);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment