.
This commit is contained in:
16
bac1/q1/livres/ex_cpp/Makefile
Normal file
16
bac1/q1/livres/ex_cpp/Makefile
Normal 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
|
16
bac1/q1/livres/ex_cpp/main.cpp
Normal file
16
bac1/q1/livres/ex_cpp/main.cpp
Normal 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
BIN
bac1/q1/livres/ex_cpp/points
Executable file
Binary file not shown.
39
bac1/q1/livres/ex_cpp/points.cpp
Normal file
39
bac1/q1/livres/ex_cpp/points.cpp
Normal 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);
|
||||
}
|
24
bac1/q1/livres/ex_cpp/points.h
Normal file
24
bac1/q1/livres/ex_cpp/points.h
Normal 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 */
|
Reference in New Issue
Block a user