From 37b003e51acde3640ec1cad1ad7f5901ffa1afd0 Mon Sep 17 00:00:00 2001 From: Yohan Boujon Date: Wed, 13 Sep 2023 15:24:27 +0200 Subject: [PATCH] Etape 2 --- src/etape2/point2d.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ src/etape2/point2d.h | 16 ++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 src/etape2/point2d.cpp create mode 100644 src/etape2/point2d.h diff --git a/src/etape2/point2d.cpp b/src/etape2/point2d.cpp new file mode 100644 index 0000000..793a78c --- /dev/null +++ b/src/etape2/point2d.cpp @@ -0,0 +1,41 @@ +#include +#include "point2d.h" + +Point2D::Point2D() + : Point2D(0,0) +{} + +Point2D::Point2D(float x) + : Point2D(x,0) +{} + +Point2D::Point2D(float x, float y) + : _x(x), _y(y) +{} + +Point2D::~Point2D() +{} + +void Point2D::Saisie(float x, float y) +{ + _x = x; + _y = y; +} + +void Point2D::Affiche() +{ + std::cout << "[POINT] X= " << _x << "\tY=" << _y << std::endl; +} + +int main(void) +{ + Point2D pointA(2.0f,3.0f); + Point2D pointB(1.0f); + Point2D pointC; + pointA.Saisie(4.31f, 5.45f); + + pointA.Affiche(); + pointB.Affiche(); + pointC.Affiche(); + return 0; +} \ No newline at end of file diff --git a/src/etape2/point2d.h b/src/etape2/point2d.h new file mode 100644 index 0000000..8cb5a7e --- /dev/null +++ b/src/etape2/point2d.h @@ -0,0 +1,16 @@ +#ifndef HEADER_POINT2D +#define HEADER_POINT2D + +class Point2D { + public: + Point2D(); + Point2D(float x); + Point2D(float x, float y); + ~Point2D(); + void Saisie(float x, float y); + void Affiche(); + private: + float _x,_y; +}; + +#endif \ No newline at end of file