Isaac87 2014. 7. 28. 12:16

circle

 

ch11_01.cpp

 

circle.cpp

 

circle.h

 

 

에어컨 - 냉난방기 예제

냉난방기.h

 #include "Aircon.h"

class 냉난방기 : public Aircon {
private:
 int 풍향;
 bool 히터;
public:
 냉난방기();
 void Up풍향();
 void Down풍향();
 void OnOff히터();
 void Print냉난방기();
};

 

냉난방기.cpp

 #include "냉난방기.h"

냉난방기::냉난방기() {
 풍향 = 0;
 히터 = false;
}

void 냉난방기::Up풍향() {
 if(풍향 < 3)
  풍향++;
}

void 냉난방기::Down풍향() {
 if(풍향 > 0)
  풍향--;
}

void 냉난방기::OnOff히터() {
 히터 = !히터;
}

void 냉난방기::Print냉난방기() {
 PrintAircon();
 cout << "현재 풍향은 " << 풍향 << "이고, ";
 cout << "히터는 ";
 if(히터)
  cout << "켜져있습니다." << endl;
 else
  cout << "꺼져있습니다." << endl;
}

 

main.cpp

#include "냉난방기.h"

int main() {
 냉난방기 a;
 a.OnOff();
 a.UpTemp();
 a.Up풍향();
 a.OnOff히터();
 a.Print냉난방기();
}