| 网站首页 | 业界新闻 | 群组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
 跟大牛学C++学算法数据结构

问题点数：0  回复次数：1

·················································

得分:0

#include<iostream>
#include<cstring>
using namespace std;
class airCondition{
public:
airCondition(string,string,string,string,int);
void switch_state(string);
void heat_up();
void heat_down();
void print();
private:
string brand;
string color;
string power;
string switc;
int heat;
};
airCondition::airCondition(string b,string c,string p,string s,int h)
{
brand=b;
color=c;
power=p;
switc=s;
heat=h;
}
void airCondition::switch_state(string s)
{
if(s=="关")
switc="开";
if(s=="开")
switc="关";
}
void airCondition::heat_up()
{
int h;
cout<<"How few degrees do you want to increase the air conditioning temperature?";
cin>>h;
heat+=h;
}
void airCondition::heat_down()
{
int h;
cout<<"How few degrees do you want to turn the air conditioning temperature down?";
cin>>h;
heat-=h;
}
void airCondition::print()
{
cout<<"The air conditioning's brand is "<<brand<<endl;
cout<<"The air conditioning's color is "<<color<<endl;
cout<<"The air conditioning's power is "<<power<<endl;
cout<<"The air conditioning's switch state is "<<switc<<endl;
cout<<"The air conditioning's temperature is "<<heat<<"°C"<<endl;
}
int main()
{
string b,c,p,s;
int h;
cout<<"Please input the air conditioning's information:"<<endl;
cout<<"The brand is :";
cin>>b;
cout<<"The color is :";
cin>>c;
cout<<"The power is :";
cin>>p;
cout<<"The switch state is :";
cin>>s;
cout<<"The temperature is :";
cin>>h;
airCondition a(b,c,p,s,h);
cout<<"The air conditioning original information:"<<endl;
a.print();
a.switch_state(s);
a.heat_down();
cout<<"The air conditioning new information:"<<endl;
a.print();
}

• 2
• 1/1页
• 1