weatherprediction.cpp
来自「C++高级编程这本书所附的源代码」· C++ 代码 · 共 45 行
CPP
45 行
#include <iostream>
#include "WeatherPrediction.h"
using namespace std;
void WeatherPrediction::setCurrentTempFahrenheit(int inTemp)
{
mCurrentTempFahrenheit = inTemp;
}
void WeatherPrediction::setPositionOfJupiter(int inDistanceFromMars)
{
mDistanceFromMars = inDistanceFromMars;
}
int WeatherPrediction::getTomorrowTempFahrenheit()
{
// Obviously, this is nonsense
return (mDistanceFromMars / 1000) + mCurrentTempFahrenheit;
}
double WeatherPrediction::getChanceOfRain()
{
// Obviously, this is nonsense too
return 0.5;
}
void WeatherPrediction::showResult()
{
cout << "Result: " << (getChanceOfRain() * 100) << " chance."
<< " Temp. " << getTomorrowTempFahrenheit() << endl;
}
/*
int main()
{
WeatherPrediction p;
p.setCurrentTempFahrenheit(24);
p.setPositionOfJupiter(80);
p.showResult();
}
*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?