This commit is contained in:
Debucquoy
2023-09-20 15:18:20 +02:00
parent 00d0cdfaf3
commit 4fd7542f03
228 changed files with 351 additions and 12 deletions

View File

@ -0,0 +1,16 @@
CXX = c++
CXXFLAGS = -Wall -g
LDFLAGS= -lm
SOURCE_POINTS= points.cpp main.cpp
all: points
points: $(SOURCE_POINTS)
$(CXX) $(CXXFLAGS) -o $@ $(SOURCE_POINTS) $(LDFLAGS)
run: points
./points
clean:
rm -f *.o ./points

View File

@ -0,0 +1,16 @@
#include "points.h"
#include <iostream>
int main(int argc, char *argv[])
{
Points p(5,5);
std::cout << p.abscisse() << ' ' << p.ordonnee() << std::endl;
std::cout << p.rho() << ' ' << p.theta() << std::endl;
p.deplace(3.1, 2);
std::cout << p.abscisse() << ' ' << p.ordonnee() << std::endl;
return 0;
}

BIN
bac1/q1/livres/ex_cpp/points Executable file

Binary file not shown.

View File

@ -0,0 +1,39 @@
#include "points.h"
#include "math.h"
Points::Points(float m_x, float m_y)
: x(m_x), y(m_y){}
// SETTERS
void Points::deplace(float m_dx, float m_dy){
x += m_dx;
y += m_dy;
}
void Points::homothetie(float k){
x *= k;
y *= k;
}
void Points::rotation(float angle){
}
// GETTERS
float Points::abscisse(){
return x;
}
float Points::ordonnee(){
return y;
}
float Points::rho(){
return sqrt(x*x + y*y);
}
float Points::theta(){
return atan(y/x);
}

View File

@ -0,0 +1,24 @@
#ifndef POINTS_H
#define POINTS_H
class Points
{
private:
float x, y;
public:
Points(float x, float y);
void deplace(float, float);
void homothetie(float);
void rotation(float);
float abscisse();
float ordonnee();
float rho();
float theta();
};
#endif /* POINTS_H */