Browse Source

My first commit

ruknez 3 years ago
commit
6775ec48c2
5 changed files with 210 additions and 0 deletions
  1. 75 0
      cLine.cpp
  2. 30 0
      cLine.h
  3. 23 0
      main.cpp
  4. 51 0
      point.cpp
  5. 31 0
      point.h

+ 75 - 0
cLine.cpp

@@ -0,0 +1,75 @@
+#include <iostream>
+
+#include "cLine.h"
+#include "point.h"
+
+using std::cout;
+using std::endl;
+//==========================
+cLine::cLine () : m_K (0), m_B (0) {}
+
+//==========================
+cLine::cLine (cPoint point1_, cPoint point2_) {
+    cout << "Надо переопределить опертатор = для класса точка \n";
+    m_point1.set_XYZ (point1_.get_X (), point1_.get_Y (), point1_.get_Z ());
+    m_point2.set_XYZ (point2_.get_X (), point2_.get_Y (), point2_.get_Z ());
+ //   m_point1.show ();
+
+//    cout << "poin1 \n"; m_point1.show ();
+//    cout << "poin2 \n"; m_point2.show ();
+    find_coff ();
+}
+
+//==========================
+cLine::cLine (double k_, double b_) {
+    m_K = k_;
+    m_B = b_;
+    find_point ();
+}
+
+//==========================
+void cLine::find_coff () {
+      m_K = (m_point1.get_Y () - m_point2.get_Y ()) / (m_point1.get_X () - m_point2.get_X ());
+      m_B = m_point1.get_Y () - m_K*(m_point1.get_X ());
+      cout << "m_K = " << m_K << endl;
+      cout << "m_B = " << m_B << endl;
+}
+
+//==========================
+void cLine::find_point () {
+    m_point1.set_Y (m_B);
+    m_point1.set_X (-(m_B/m_K));
+
+    cout << "что делать со второй точкой??? \n";
+}
+
+//==========================
+void cLine::show () {
+    cout << "\t I am  a line \n";
+    cout << "m_K = " << m_K << endl;
+    cout << "m_B = " << m_B << endl;
+    cout << "\t My first point \n";
+ //   m_point1.show ();
+    cout << "\n \t My second point \n";
+ //   m_point2.show ();
+
+}
+
+//==========================
+bool cLine::Ok () {
+    cout << "Not now \n";
+    return false;
+}
+
+//==========================
+bool cLine::parallel_me (cLine line1_) {
+    if (m_K == line1_.get_K()) {
+        cout << "\t PARALLEL \n";
+        return true;
+    }
+    else {
+       cout << "\t Not PARALLEL \n";
+        return false;
+    }
+
+}

+ 30 - 0
cLine.h

@@ -0,0 +1,30 @@
+#ifndef __LINE_H__
+#define __LINE_H__
+
+#include "point.h"
+
+class cLine {
+    public:
+        cLine ();
+        cLine (cPoint point1_, cPoint point2_);
+        cLine (double k_, double b_);
+
+        bool Ok ();
+        void show ();
+
+        bool parallel_me (cLine line1_);
+
+        double get_K () {return m_K;}
+    private:
+        void find_coff ();
+        void find_point ();
+
+        cPoint m_point1;
+        cPoint m_point2;
+
+        double m_K;
+        double m_B;
+
+};
+
+#endif

+ 23 - 0
main.cpp

@@ -0,0 +1,23 @@
+#include <iostream>
+#include "point.h"
+#include "cLine.h"
+
+int main()
+{
+    cPoint point1 (2, 0);
+    cPoint point2 (4, 6);
+
+    cPoint point3 (4, 6);
+    cPoint point4 (8, 77);
+
+    //point2.show ();
+
+    cLine lin1 (point1, point2);
+    lin1.show ();
+
+    cLine lin2 (3, 6);
+
+    lin1.parallel_me(lin2);
+
+return 0;
+}

+ 51 - 0
point.cpp

@@ -0,0 +1,51 @@
+#include <iostream>
+
+#include "point.h"
+
+//==========================
+cPoint::cPoint () : m_X (-999),m_Y (-999), m_Z (-999) {}
+cPoint::~cPoint () {}
+//==========================
+cPoint::cPoint (double x_, double y_, double z_) {
+    m_X = x_;
+    m_Y = y_;
+    m_Z = z_;
+}
+
+//==========================
+void cPoint::set_XYZ (double x_, double y_, double z_) {
+    m_X = x_;
+    m_Y = y_;
+    m_Z = z_;
+}
+
+//==========================
+void cPoint::set_X (double x_) {
+     m_X = x_;
+}
+
+//==========================
+void cPoint::set_Y (double y_) {
+     m_Y = y_;
+}
+
+//==========================
+void cPoint::set_Z (double z_) {
+     m_Z = z_;
+}
+
+//==========================
+bool cPoint::Ok () {
+
+   std::cout << "NOT finish \n";
+}
+
+//==========================
+void cPoint::show () {
+  //  std::cout << __FILE__ << "   "<<_FUNC_ << std::endl;
+    std::cout << "\t\t SHOW POINT \n";
+    std::cout << "X = " <<  m_X << std::endl;
+    std::cout << "Y = " <<  m_Y << std::endl;
+    std::cout << "Z = " <<  m_Z << std::endl;
+}
+

+ 31 - 0
point.h

@@ -0,0 +1,31 @@
+#ifndef __POINT_H__
+#define __POINT_H__
+
+class cPoint {
+    public:
+        cPoint ();
+        cPoint (double x_, double y_, double z_ = -999);
+        ~cPoint ();
+
+        bool Ok ();
+        void show ();
+
+        void set_XYZ (double x_, double y_, double z_ = -999);
+        void set_X (double x_);
+        void set_Y (double y_);
+        void set_Z (double z_);
+
+        double get_X () { return m_X;}
+        double get_Y () { return m_Y;}
+        double get_Z () { return m_Z;}
+
+    private:
+        double m_X;
+        double m_Y;
+        double m_Z;
+
+};
+
+
+
+#endif