Created
August 23, 2011 18:20
-
-
Save yuripiratello/1166063 to your computer and use it in GitHub Desktop.
Temperatura
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Codigo de definicao: temperatura.h | |
*/ | |
#ifndef TEMPERATURA_H | |
#define TEMPERATURA_H | |
class Temperatura{ | |
public: | |
Temperatura(); | |
Temperatura(float temperatura_atual); | |
void esquenta(); | |
void esfria(); | |
float temperaturaAtual(); | |
float termometro; | |
}; | |
void Temperatura::esquenta(){ // esquenta a temperatura | |
this->termometro = this->termometro + 5; | |
} | |
void Temperatura::esfria(){// esfria a temperatura | |
this->termometro = this->termometro - 4; | |
} | |
float Temperatura::temperaturaAtual(){ // retorna a temperatura | |
return this->termometro; | |
} | |
Temperatura::Temperatura() { // construtor padrao | |
this->termometro = 0; | |
} | |
Temperatura::Temperatura(float temperatura_atual) { // construtor com parametros | |
this->termometro = temperatura_atual; | |
} | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include "temperatura.h" | |
using namespace std; | |
int main(int argc, char *argv[]) | |
{ | |
// declara um objeto da classe Temperatura e informa a temperatura | |
Temperatura t(7.5); | |
printf("\nTemperatura atual: %4.2f",t.temperaturaAtual()); | |
// esquenta e informa a temperatura | |
t.esquenta(); | |
printf("\nEsquentando... (+5)"); | |
printf("\nTemperatura atual: %4.2f",t.temperaturaAtual()); | |
// esfria e informa a temperatura | |
t.esfria(); | |
printf("\nEsfriando...(-4)"); | |
printf("\nTemperatura atual: %4.2f\n",t.temperaturaAtual()); | |
system("PAUSE"); // pausa o programa | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment