From fd004988d66ae97490d9b58724a340adc14bf446 Mon Sep 17 00:00:00 2001 From: p2405951 Date: Wed, 18 Jun 2025 14:48:58 +0200 Subject: [PATCH 1/2] classe step --- sae201.pro | 6 ++++-- step.cpp | 22 ++++++++++++++++++++++ step.h | 22 ++++++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 step.cpp create mode 100644 step.h diff --git a/sae201.pro b/sae201.pro index b915c09..1e37e62 100644 --- a/sae201.pro +++ b/sae201.pro @@ -10,10 +10,12 @@ CONFIG += c++17 SOURCES += \ main.cpp \ - mainwindow.cpp + mainwindow.cpp \ + step.cpp HEADERS += \ - mainwindow.h + mainwindow.h \ + step.h FORMS += \ mainwindow.ui diff --git a/step.cpp b/step.cpp new file mode 100644 index 0000000..1e80c51 --- /dev/null +++ b/step.cpp @@ -0,0 +1,22 @@ +#include "step.h" + +Step::Step() { + latitude = 0.0; + longitude = 0.0; + response = 0; +} + +Step::Step(QTextStream &in) +{} +void Step::setLatitude(int degree, float minute, QChar NS) +{ + latitude = degree + minute / 60.0; + if (NS.toUpper() == 'S') + latitude = -latitude; +} +void Step::setLongitude(int degree, float minute, QChar EW) +{ + longitude = degree + minute / 60.0; + if (EW.toUpper() == 'W') + longitude = -longitude; +} diff --git a/step.h b/step.h new file mode 100644 index 0000000..eb46bbc --- /dev/null +++ b/step.h @@ -0,0 +1,22 @@ +#ifndef STEP_H +#define STEP_H +#include +#include +class Step +{ + +private: + QString title; + float latitude; + float longitude; + QString text; + int response; + +public: + Step(); + Step(QTextStream &in); + void setLatitude(int degree,float minute,QChar NS); + void setLongitude(int degree,float minute,QChar EW); +}; + +#endif // STEP_H From 5f2bb19da9bfe9a414961304f386a925e9b5ce7b Mon Sep 17 00:00:00 2001 From: p2405951 Date: Wed, 18 Jun 2025 15:07:36 +0200 Subject: [PATCH 2/2] constructeur step --- main.cpp | 3 +++ step.cpp | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index fd3e533..4b6acc2 100644 --- a/main.cpp +++ b/main.cpp @@ -1,11 +1,14 @@ #include "mainwindow.h" #include +#include int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); + + return a.exec(); } diff --git a/step.cpp b/step.cpp index 1e80c51..17f2edc 100644 --- a/step.cpp +++ b/step.cpp @@ -7,7 +7,20 @@ Step::Step() { } Step::Step(QTextStream &in) -{} +{ + int stepNumber; + in >> stepNumber; + in.readLine(); + title = in.readLine(); + QChar latDir, lonDir; + int latDeg, lonDeg; + float latMin, lonMin; + in >> latDir >> latDeg >> latMin >> lonDir >> lonDeg >> lonMin; + setLatitude(latDeg, latMin, latDir); + setLongitude(lonDeg, lonMin, lonDir); + in >> response; + in.readLine(); +} void Step::setLatitude(int degree, float minute, QChar NS) { latitude = degree + minute / 60.0;