From f9b655d9cedb128916db2d569cfff755ce275c3f Mon Sep 17 00:00:00 2001 From: bray Date: Wed, 20 May 2020 09:58:06 +0200 Subject: [PATCH] Modif terrarium et creation TerrariumParameter --- app/include/Terrarium.h | 19 +--------------- app/include/TerrariumParameter.h | 30 +++++++++++++++++++++++++ app/src/Terrarium.cpp | 35 ++--------------------------- app/src/TerrariumParameter.cpp | 38 ++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 51 deletions(-) create mode 100644 app/include/TerrariumParameter.h create mode 100644 app/src/TerrariumParameter.cpp diff --git a/app/include/Terrarium.h b/app/include/Terrarium.h index 876c24f..14d770a 100644 --- a/app/include/Terrarium.h +++ b/app/include/Terrarium.h @@ -9,33 +9,16 @@ class Terrarium { private: int id; - float temperature; - float pression; - float PH; int radState; int tapState; public: Terrarium(int id); - float getTemperature() const; - - void setTemperature(float temperature); - - float getPression() const; - - void setPression(float pression); - - float getPh() const; - - void setPh(float ph); - int getRadState() const; - void setRadState(int radState); - int getTapState() const; - void setTapState(int tadState); + }; diff --git a/app/include/TerrariumParameter.h b/app/include/TerrariumParameter.h new file mode 100644 index 0000000..835b36a --- /dev/null +++ b/app/include/TerrariumParameter.h @@ -0,0 +1,30 @@ +// +// Created by camer on 20/05/2020. +// + +#ifndef PROJET_VICTORAVECUNK_TERRARIUMPARAMETER_H +#define PROJET_VICTORAVECUNK_TERRARIUMPARAMETER_H + + +class TerrariumParameter { //TODO add to diagram +private: + float value; + int thresholdHigh; + int thresholdLow; +public: + TerrariumParameter(int thresholdHigh, int thresholdLow); + + //getters setters + float getValue() const; + void setValue(float value); + int getThresholdHigh() const; + void setThresholdHigh(int thresholdHigh); + int getThresholdLow() const; + void setThresholdLow(int thresholdLow); + + bool is2High(); + bool is2Low(); +}; + + +#endif //PROJET_VICTORAVECUNK_TERRARIUMPARAMETER_H diff --git a/app/src/Terrarium.cpp b/app/src/Terrarium.cpp index 6d62e45..5231581 100644 --- a/app/src/Terrarium.cpp +++ b/app/src/Terrarium.cpp @@ -4,30 +4,8 @@ #include "../include/Terrarium.h" #include "../../core_simulation.h" - -float Terrarium::getTemperature() const { - return temperature; -} - -void Terrarium::setTemperature(float temperature) { - Terrarium::temperature = temperature; -} - -float Terrarium::getPression() const { - return pression; -} - -void Terrarium::setPression(float pression) { - Terrarium::pression = pression; -} - -float Terrarium::getPh() const { - return PH; -} - -void Terrarium::setPh(float ph) { - PH = ph; -} +Terrarium::Terrarium(int id) : id(id), +radState(LOW), tapState(LOW){} int Terrarium::getRadState() const { return radState; @@ -45,12 +23,3 @@ void Terrarium::setTapState(int tapState) { Terrarium::tapState = tapState; } -Terrarium::Terrarium(int id) { - id = id; - pression = 3000; - temperature = 20; - PH = 7; - radState = LOW; - tapState = LOW; - -} diff --git a/app/src/TerrariumParameter.cpp b/app/src/TerrariumParameter.cpp new file mode 100644 index 0000000..49dd201 --- /dev/null +++ b/app/src/TerrariumParameter.cpp @@ -0,0 +1,38 @@ +// +// Created by camer on 20/05/2020. +// + +#include "../include/TerrariumParameter.h" +//Constructor +TerrariumParameter::TerrariumParameter(int thresholdHigh, int thresholdLow) : thresholdHigh(thresholdHigh), + thresholdLow(thresholdLow) {} + +//Getters Setters +float TerrariumParameter::getValue() const { + return value; +} +void TerrariumParameter::setValue(float value) { + TerrariumParameter::value = value; +} +int TerrariumParameter::getThresholdHigh() const { + return thresholdHigh; +} +void TerrariumParameter::setThresholdHigh(int thresholdHigh) { + TerrariumParameter::thresholdHigh = thresholdHigh; +} +int TerrariumParameter::getThresholdLow() const { + return thresholdLow; +} +void TerrariumParameter::setThresholdLow(int thresholdLow) { + TerrariumParameter::thresholdLow = thresholdLow; +} + +//Methods +bool TerrariumParameter::is2High() { + return this->value > this->thresholdHigh; +} + +bool TerrariumParameter::is2Low() { + return this->value < this->thresholdLow; +} +