图片附件: 游客没有浏览图片的权限,请
登录 或
注册
#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();
}
程序比较简单粗糙,希望楼主够用